3

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?

halfer
  • 18,701
  • 13
  • 79
  • 158
mack
  • 2,298
  • 8
  • 33
  • 56
  • 1
    Why don't you just install SQL Server? The [developer edition is free](https://www.microsoft.com/en-ca/sql-server/sql-server-downloads). 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 off – Liam Dec 21 '18 at 14:40

1 Answers1

2

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.

Erik A
  • 28,352
  • 10
  • 37
  • 55