具有Microsoft Access的实体框架 [英] Entity Framework with Microsoft Access

查看:192
本文介绍了具有Microsoft Access的实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用.accdb文件。我使用System.Data.Entity创建了类

I use .accdb file. I created class

using System.Data.Entity;

    class MSADbContext:DbContext
    {
        public DbSet<Product> Products { get; set; }
    }

并添加connectionString

and add connectionString

<add name="MSADbContext" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\SportsStore.accdb" providerName="System.Data.OleDb"/>

在首次查询数据库后,我得到了ProviderIncompatibleException:在存储库typeOf中调用get_ProviderFactory。 data.OleDb.OleDbConnection返回null

After first query to DB I get the ProviderIncompatibleException: "calling "get_ProviderFactory" in repository typeOf "System.Data.OleDb.OleDbConnection" returns null"

推荐答案

您的连接字符串将是.mdb(Access 2003-)文件。检查连接这里的字符串

Your connection-string would be for an .mdb (Access 2003-) file. Check connection strings here

您需要ACE OLEDB提供商。标准安全性:

You need the ACE OLEDB provider. Standard Security:

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;
Persist Security Info=False;

但是,请阅读这个线程首先:


实体框架不支持OLEDB连接,所以你的
连接字符串将不起作用。实际上不可能得到
实体框架与MS Access协作。

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.

几乎不可能非常有吸引力。

这篇关于具有Microsoft Access的实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆