I'm new to Entity Framework, and I was trying to develop a simple C# script today, which would use Entity Framework Core Jet in order to list all of the companies specified in local MS Access DB.
However, I keep getting an error in "OnConfiguring" function, which says:
System.TypeLoadException: 'Method 'get_Info' in type 'EntityFrameworkCore.Jet.Infrastructure.Internal.JetOptionsExtension' from assembly 'EntityFrameworkCore.Jet, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.'
Note that the C# console application I'm developing is being developed in .NET framework 4.7.2. I've also tried developing the same script with .NET Core 3, .NET Core 2.1 etc. but all of these had the same outcome.
I'm providing below all the information on the database and the code I wrote so far.
Database design
Database contains only one table called "Companies", which contains the following fields:
DataContext.cs
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using EntityFrameworkCore.Jet;
namespace EntityFrameworkCoreJetTest5 {
public class DataContext : DbContext {
public DbSet<Company> Companies { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
//The issue occurrs here
optionsBuilder.UseJet(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\arand\Desktop\EFTestProject\Data\Data.accdb;");
}
}
public class Company {
public int ID { get; set; }
public string CompanyName { get; set; }
}
}
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EntityFrameworkCoreJetTest5 {
class Program {
static void Main(string[] args) {
using (DataContext dbContext = new DataContext()) {
foreach(Company c in dbContext.Companies) {
Console.WriteLine(c.CompanyName);
}
}
Console.ReadKey();
}
}
}
Thank you!
System.TypeLoadException: 'Method 'get_Info' in type 'EntityFrameworkCore.Jet.Infrastructure.Internal.JetOptionsExtension' from assembly 'EntityFrameworkCore.Jet, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.'
The EntityFrameworkCore.Jet
provider in version 2.2.0
is only compatible with EF Core 2.2.x. So it won't work with EF Core 3.0.0+.
If you want to use EntityFrameworkCore.Jet
with EF Core 3.1, use our latest official prerelease (as of this date, this is 3.1.0-alpha.3
) from nuget.org, or use the latest daily build from our AZDO feed.
It is .NET Standard 2.0 compliant, so it works with .NET Framework 4.6.1+ and .NET (Core) 2.0+.