我使用.accdb文件.我创造了课程
using System.Data.Entity; class MSADbContext:DbContext { public DbSet<Product> Products { get; set; } }
并添加connectionString
<add name="MSADbContext" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\SportsStore.accdb" providerName="System.Data.OleDb"/>
在第一次查询到DB之后,我得到ProviderIncompatibleException:“在存储库typeOf中调用”get_ProviderFactory“System.Data.OleDb.OleDbConnection”返回null“
您的连接字符串将用于.mdb(Access 2003-)文件.检查连接
strings here
您需要ACE OLEDB提供程序.标准安全:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb; Persist Security Info=False;
但是,请先阅读this thread:
Entity Framework does not support OLEDB connections,so your
connection string will not work. It is practically impossible to get
Entity Framework to collaborate with MS Access.
几乎不可能是非常引人注目的.