c# - Entity Framework 核心和 MS Access

标签 c# ms-access entity-framework-core jet-ef-provider

我正在尝试使用来自 WPF MVVM 应用程序的 Access 数据库 JetEntityFrameworkProvider我无法让它工作。我已经创建了模型,使用 Add-Migration 创建了迁移,但是当我运行 Update-Database 时,命令永远不会完成。它确实创建了数据库,但唯一的表是 MSysAccessStorage。有一段documentation就是说

In order to make the provider work, the table MSysRelationships should be accessible from Administrator

进一步说

This is the default configuration so no needs to make changes. Access since version 2003 has visible system tables so no need to assign rights. The configuration must be done setting the right dual table (very early in your code).

JetConnection.DUAL = JetConnection.DUALForAccdb;

我试过添加这个,但我不知道“在你的代码中很早”在哪里。我已将它添加到我的 App.xaml.cs 的顶部和我的数据库上下文中,但都没有用。当我添加它时,我得到:

The name 'DUAL' does not exist in the current context. The name 'JetConnection.DUALForAccdb' does not exist in the current context.

这是我的上下文中的 OnConfiguring

protected override void OnConfiguring( DbContextOptionsBuilder optionsBuilder )
{
    optionsBuilder.UseJet( @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\<User>\Desktop\New Folder\Staff.accdb;" );
}

我做错了什么?

最佳答案

JetEntityFramework 提供程序与 EF Core 不兼容。

相反,使用 EntityFrameworkCore.Jet如果您想使用 EF Core(与 JetEntityFramework 是同一作者,不隶属于),或者如果您想使用 JetEntityFramework,请使用 EF 6。

关于c# - Entity Framework 核心和 MS Access,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53886401/

相关文章:

ms-access - 在 Access 表单中过滤

c# - 来自 Include 的 EF Core 查询但无需返回结果

.net-core - CS0120 非静态字段、方法或属性需要对象引用 'Startup.Configuration'

c# - Rhino.Mocks 和 ref 参数

ms-access - 检索 Access 表的下一个自动编号

r - 带有 Access DB 的 R 中的 ODBC 是否存在任何语言问题?

c# - Entity Framework 核心 - 不在

c# - 通过参数名称对 ArgumentNullException 进行单元测试

c# - 在 ASP.NET 应用程序中将图像从 JavaScript 传递到 C#?

c# - LINQ 与 GROUP BY 和 HAVING COUNT