Entity Framework Core and MS Access
Asked Answered
T

1

6

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?

Teniers answered 21/12, 2018 at 14:26 Comment(2)
Why don't you just install SQL Server? The developer edition is free. If your planning on developing anything except a quick home test then Access is going to be lacking. You'd be better off learning to use proper tools from the offSouse
Because we don't want to have our DB in client-server architectureThorr
C
5

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.

Crabtree answered 21/12, 2018 at 15:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.