简体   繁体   中英

Entity Framework Core and MS Access

I'm attempting to use an Access database from a WPF MVVM application using JetEntityFrameworkProvider and I can't get it to work. I've created the models, created the migrations using Add-Migration but when I run Update-Database, the command never finishes. It does create the database but the only table is MSysAccessStorage. There is a section of the documentation that says

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

and further says

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;

I've tried adding this but I can't figure out where "very early in your code" is. I've added it to the top of my App.xaml.cs and to my database context and neither worked. When I add it I get:

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

This is my OnConfiguring in my context

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

What am I not doing correctly?

The JetEntityFramework provider is not compatible with EF Core.

Instead, use EntityFrameworkCore.Jet if you want to use EF Core (same author as JetEntityFramework, not affiliated), or use EF 6 if you want to use JetEntityFramework.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM