Search code examples
c#asp.net-mvcms-accesstypeloadexceptionjet-ef-provider

Scaffold existing local MS Access via .NET Framework: System.TypeLoadException: Method 'Create' in EntityFrameworkCore.Jet not implemented


I want to represent the datas of an existing local Access DB on a Homepage. For that I use ASP.NET MVC with Framework 4.7.2. I have to use EntityFrameworkCore.Jet, so I can't use Core. Following packages were installed:

  • Microsoft.EntityFrameworkCore.Design
  • Microsoft.EntityFrameworkCore.Tools
  • EntityFrameworkCore.Jet

So I try to scaffold my Database in the Package-Manager-Console:

Scaffold-DbContext “Data Source=C:\...\AKneu.mdb” EntityFrameworkCore.Jet -OutputDir Models

But it throws back an Error:

System.TypeLoadException: The method "Create" in the type "EntityFrameworkCore.Jet.Scaffolding.Internal.JetDatabaseModelFactory" of the assembly "EntityFrameworkCore.Jet, Version = 2.2.0.0, Culture = neutral, PublicKeyToken = adb9793829ddae60" has no implementation.

I couldn't find a reason why it can't find the assembly. Do you have anything in mind, why it doesn't work?


Solution

  • To use scaffolding you need to use Visual Studio 2015, this is mentioned in the wiki of the GitHub project:

    If you already have a database, your can use the Package Manager Console Scaffold-DbContext command to create your model classes from an existing database. This feature is only available in Visual Studio 2015.

    I had a similar issue a while ago and noted that in order for scaffolding to work you also need to use the version 2.1.2 of EntityFrameworkCore and the 2.0.0 version of the Jet-Provider. Unfortunately I did not note why this was needed, but it may help you.