我正在尝试使用来自 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/