实体框架 – 使用Microsoft Access的实体框架

前端之家收集整理的这篇文章主要介绍了实体框架 – 使用Microsoft Access的实体框架前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用.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.

几乎不可能是非常引人注目的.

原文链接:https://www.f2er.com/windows/363678.html

猜你在找的Windows相关文章