-1

So i made a new asp .net mvc application and just I still get this error ,

when I run it then show error "Unable to find the requested .Net Framework Data Provider" and if entered id in url like "localhost/MVC_Demo/employee/Details/2" then it show error in ...Please tell me how to solve? EmployeeContext.cs file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;

namespace MVC_Demo.Models
{
    public class EmployeeContext : DbContext
    {
        public DbSet<Employee> Employee { get; set; }   
    }
}

EmployeeController.cs file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVC_Demo.Models;

namespace MVC_Demo.Controllers
{
    public class EmployeeController : Controller
    {

        public ActionResult Details(int id)
        {
            EmployeeContext employeeContext = new EmployeeContext();
            Employee employee = employeeContext.Employee.Single(emp => emp.ID == id);

            return View(employee);
        }
    }
}

Web.config

<connectionStrings>
    <add name="EmployeeContext" connectionString="Server=.; database=dbEmployees; Integrated Security=SSPI" providerName="System.Data.Client" />
  </connectionStrings>

Employee.cs File

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;

namespace MVC_Demo.Models
{
    [Table("Emp")]
    public class Employee
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public string Gender { get; set; }
        public string City { get; set; }
        public int Salary { get; set; }
    }
}
IronAces
  • 1,857
  • 1
  • 27
  • 36
  • possibly this link may help. https://stackoverflow.com/questions/9928361/unable-to-find-the-requested-net-framework-data-provider-in-visual-studio-2010 – It's a trap Sep 06 '17 at 12:20

1 Answers1

1

this works fine,

<system.data>
    <DbProviderFactories >
        <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
</system.data>
Sanjay Kumaar
  • 690
  • 7
  • 17