所以我做了一個新的ASP.NET MVC應用程序,只是我仍然得到這個錯誤,無法找到所請求的數據提供
當我運行它,然後顯示錯誤「無法找到請求的.NET Framework數據提供「,如果輸入id像」本地主機/ MVC_Demo /員工/詳細/ 2「 然後它顯示錯誤...請告訴我如何解決? EmployeeContext.cs文件
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文件
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文件
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; }
}
}
此鏈接可能會有所幫助。 https://stackoverflow.com/questions/9928361/unable-to-find-the-requested-net-framework-data-provider-in-visual-studio-2010 –