EntityFrameworkCore.Jet icon indicating copy to clipboard operation
EntityFrameworkCore.Jet copied to clipboard

EF Core 5 support

Open lauxjpn opened this issue 3 years ago • 26 comments

We will use this issue to track the progress on supporting EF Core 5.

lauxjpn avatar May 22 '21 08:05 lauxjpn

@ChrisJollyAU I think we should make this one comply with what's expected for EF Core 5, ensure the tests that did run before still run now, and get this out the door. Split queries are basically a must for Jet.

I propose moving any real new features and major work to the EF Core 6 support, so we can release in parallel to their release upstream in November.

lauxjpn avatar May 22 '21 09:05 lauxjpn

So more of a compatibility update? Can do go with that

ChrisJollyAU avatar May 22 '21 09:05 ChrisJollyAU

Do you plan to publish the daily builds in your Azure DevOps feed? Thanks in advance for your all your work!

francescomazzurco avatar Jul 12 '21 09:07 francescomazzurco

Do you plan to publish the daily builds in your Azure DevOps feed?

@francescomazzurco Yes, every merge automatically makes it into the daily build feed.

lauxjpn avatar Jul 13 '21 08:07 lauxjpn

@lauxjpn What's the current plan? .Net 6 is already here

ChrisJollyAU avatar Nov 24 '21 12:11 ChrisJollyAU

@lauxjpn @bubibubi Hello there! How can I obtaion some test build with EF Core 5 (or even EF Core 6) support? Thank you.

bairog avatar Dec 10 '21 08:12 bairog

@bairog

I have scheduled time on Sunday to fix the tests and merge this.

lauxjpn avatar Dec 10 '21 13:12 lauxjpn

@bairog If you feel like it, give the attached a try. They are currently a work in progress. The EF5/Net5 is at the exact stage the the .Net 5 pull request is at. Compiled from my net5structure branch https://github.com/ChrisJollyAU/EntityFrameworkCore.Jet/tree/net5structure The .Net 6 (my branch https://github.com/ChrisJollyAU/EntityFrameworkCore.Jet/tree/net6) is copied from the .Net 5 and updated so that it can compile. I've done some basic reading and writing in it but no idea on the more complex stuff ef6.zip ef5.zip

Unzip to the project and manually add as reference.

If you prefer a nuget package, you may have to wait for @lauxjpn to finish the tests and merge so that it will show in the nightly builds

ChrisJollyAU avatar Dec 10 '21 15:12 ChrisJollyAU

@ChrisJollyAU Thank you for your work. I've tried to test your ef6.zip.

Database that I need to query has a lot of specific: table names are Cyrillic, tables has no primary key, colums names are Cyrillic. So I've created .NET 6.0 class library, added EntityFrameworkCore.Jet.dll, EntityFrameworkCore.Jet.Data.dll and EntityFrameworkCore.Jet.OleDb.dll as a library reference and wrote the following code:

My entites and DbContext in a .NET 6.0 class library
public partial class TechnicalLibraryCatalogItem
    {
        public Int32? OrderNo { get; set; }

        public String? InventoryNo { get; set; }
    }

public partial class TechnicalLibraryContext : DbContext
    {
        public TechnicalLibraryContext()
        {
        }

        public TechnicalLibraryContext(DbContextOptions<TechnicalLibraryContext> options)
            : base(options)
        {
        }

        public virtual DbSet<TechnicalLibraryCatalogItem> TechnicalLibraryCatalogItems { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
                optionsBuilder.UseJet(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=EKTB.mdb;");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<TechnicalLibraryCatalog>().HasNoKey();
            modelBuilder.Entity<TechnicalLibraryCatalog>().ToTable("Каталог ТБ");
            modelBuilder.Entity<TechnicalLibraryCatalog>().Property(tlc => tlc.OrderNo).HasColumnName("№ п/п");
            modelBuilder.Entity<TechnicalLibraryCatalog>().Property(tlc => tlc.InventoryNo).HasColumnName("Инв  №");
        }
    }
My code to read data from ASP .NET Core 6.0 Web App
using (var scope = app.Services.CreateScope())
    {
        var services = scope.ServiceProvider;        

        using (var context = services.GetRequiredService<TechnicalLibraryContext>())
        {
             var lst = context.TechnicalLibraryCatalogItems.ToList();
        }
    }

I've compiled it but get the following error in runtime at .UseJet() line

System.TypeLoadException: 'To use OLE DB in conjunction with Jet, please reference the 'System.Data.OleDb' (version >= 5.0.0) NuGet package.'

I've added a nuget reference for latest System.Data.OleDb 6.0.0 to a class library project and now I have the following error on context.TechnicalLibraryCatalogItems.ToList() line:

System.ArgumentNullException: "Value cannot be null. (Parameter 'provider')"

Stack trace
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel(Boolean designTime)
   at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()
   at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder.<>c.<TryAddCoreServices>b__8_4(IServiceProvider p)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass2_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
   at Microsoft.EntityFrameworkCore.DbContext.get_ContextServices()
   at Microsoft.EntityFrameworkCore.DbContext.get_Model()
   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityType()
   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.CheckState()
   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityQueryable()
   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.System.Collections.Generic.IEnumerable<TEntity>.GetEnumerator()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Program.<<Main>$>g__CreateDatabaseIfNotExists|0_3(WebApplication app) in D:\Tabit.NET_DBPlanov\DBPlanov.Web\Program.cs:line 109

After that I've tried to reverse engineer my existing MS Access database as advised in wiki. In Package Manager Console (Tools –> NuGet Package Manager –> Package Manager Console) I've wrote Install-Package Microsoft.EntityFrameworkCore.Tools and after that: Scaffold-DbContext -Connection "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\MyDB.mdb;" -Provider EntityFrameworkCore.Jet But it failed with an error:

System.InvalidOperationException: Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger`1[Microsoft.EntityFrameworkCore.DbLoggerCategory+Scaffolding]' while attempting to activate 'EntityFrameworkCore.Jet.Scaffolding.Internal.JetDatabaseModelFactory'.

Stack trace
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames, Boolean suppressOnConfiguring, Boolean noPluralize)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames, Boolean suppressOnConfiguring, Boolean noPluarlize)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_0.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)

In MS docs there is only Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger for EF Core 5.0, not for EF Core 6.0. So I'm in a deadend for now. Any advices are appreciated. Thank you in advance.

bairog avatar Dec 13 '21 06:12 bairog

You might be missing some references image Need all 3

ChrisJollyAU avatar Dec 13 '21 07:12 ChrisJollyAU

@ChrisJollyAU Unfortunatelly I've already tried that with no success (errors are the same). All three libraries (as well as System.Data.OleDb.dll) are present in output directory. I've updated my initial post above. P. S. I've also tried to call my class library API from a console app instead of ASP .NET Core 6.0 Web App - nothing changes.. Maybe you can share a working example for data reading that you've performed your tests on?

bairog avatar Dec 13 '21 07:12 bairog

I don't see any thing related to Jet in the stack traces. Looks like it's just around in ef core.

Also, not sure what you're trying to do with the scope and serviceProvider. DbContextOptionsBuilder builder = new DbContextOptionsBuilder<ModelContext>(); builder.UseJet("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\test\\recent.mdb;").UseLazyLoadingProxies(); context = new ModelContext((DbContextOptions<ModelContext>)builder.Options);

That's how I do it in my console program. Then just use context as normal

ChrisJollyAU avatar Dec 13 '21 07:12 ChrisJollyAU

@ChrisJollyAU Just changed my code to this - unfortunatelly same error

DbContextOptionsBuilder builder = new DbContextOptionsBuilder<TechnicalLibraryContext>(); 
builder.UseJet("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\MyDB.mdb;"); 
var context = new TechnicalLibraryContext((DbContextOptions<TechnicalLibraryContext>)builder.Options);
var lst = context.TechnicalLibraryCatalogItems.ToList();

Ok, I will try to perform a test with "traditional" MS database (with English table names and column names) - maybe that is the core of the problem here...

bairog avatar Dec 13 '21 07:12 bairog

@ChrisJollyAU Same error with "traditional" MS database. Could you please share a full code of your EF6 test console app (including test database) - so I could finally find the real core of my problem? Thank you in advance..

bairog avatar Dec 13 '21 07:12 bairog

Actually, might have the same problem on ef6. It is experimental right now. Also perhaps should have a separate issue for ef6 experimental stuff

ChrisJollyAU avatar Dec 13 '21 08:12 ChrisJollyAU

@bairog @ChrisJollyAU I moved the recent posts to #111.

lauxjpn avatar Dec 13 '21 16:12 lauxjpn

A 5.0 alpha prerelease is now available via our daily builds feed.

lauxjpn avatar Dec 13 '21 16:12 lauxjpn

For the 5.0 GA release, we have to ensure that all tests that worked in 3.1 are still working (at a first glance, it looks pretty good). We will also need feedback from the community regards any issue their existing applications have with the new release.

lauxjpn avatar Dec 13 '21 16:12 lauxjpn

A 5.0 alpha prerelease is now available via our daily builds feed.

@lauxjpn @ChrisJollyAU I've tested 5.0 alpha prerelease in my console application with .net5.0-windows7.0 TFM. Basic reading with .Where() filtering is working as expected.

P. S. I have x86 version of MS Office 2010 installed. I had to switch my test project to x86, because I got an error with AnyCPU:

The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine

Is there any way to make you provider work in AnyCPU test projects? Installing x64 version of Microsoft Access Database Engine 2010 Redistributable (even with a /passive flag trick) is not an option for me - it breaks my existing x86 MS Office installation. Wiki page tells us that The provider published on NuGet is compiled with AnyCPU Platform. - so I suppose there should be a workaround for this. Thank you in advance.

bairog avatar Dec 14 '21 07:12 bairog

@bairog If the provider you have installed is x86 you have to target your project for x86. Similar for x64. It's just one of those things with using the access database engine - target the platform of the engine you have installed. And as you have found out, it's also not really doable/easy to have x86 and x64 installed side by side

As to the nuget being as AnyCPU, that's just so that the same package can be used in projects that target either x86 or target x64. Otherwise you may have ended up with a nuget package specifically for x86 projects and a different package for x64 and you would have to change the package if you changed your target platform

Also as to the project targeting AnyCPU, as far as I understand it, on a 32 bit OS it will run as 32bit/x86 (and you probably wouldnt notice any problems). On x64 systems it will run as x64

ChrisJollyAU avatar Dec 14 '21 07:12 ChrisJollyAU

@bairog AnyCPU basically means "I can and will be compiled to whatever the target OS or host process architecture is when I am being executed". Nowadays, most machines run a 64 bit OS version.

If the app is compiled to 64 bit, it runs in a 64 bit process. A 64 bit process can only load 64 bit compiled libraries. Because of that, there is also a 64 bit dedicated registry hive for COM components (OLE DB is implemented using COM). If no 64 bit compiled ACE/Jet OLE DB provider has been registered in that hive, your 64 bit app cannot use it to access ACE/Jet databases via OLE DB.

The same is true for 32 bit apps respectively.


If you cannot install a 64 bit version of ACE/Jet, then your app needs to run as a 32 bit process to access the 32 bit libraries (either the ones explicitly installed by you, or the legacy ones that ship with Windows).

Since you are building a .NET 5 app, there should be at least two options for you to run your app as 32 bit:

  • Compile the app as x86 and run its EXE file
  • Compile the app as AnyCPU and run its DLL via the 32 bit .NET Host Process (C:\Program Files (x86)\dotnet\dotnet.exe)

lauxjpn avatar Dec 14 '21 14:12 lauxjpn

In my daily use, the 5.0 bits work fine. So unless there are any objections, I suggest we publish those bits as a beta and then go GA after that.

lauxjpn avatar Feb 08 '22 11:02 lauxjpn

I think there have been some fixes in the 3.1 branch since this was merged to the main branch. Just to confirm those have been ported to the .Net5 main branch?

If so then should be fine for beta

ChrisJollyAU avatar Feb 10 '22 11:02 ChrisJollyAU

Anyone have issues with transactions? These were good in the 3x versions.

Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.

horseyhorsey avatar Jun 07 '22 14:06 horseyhorsey

Anyone have issues with transactions? These were good in the 3x versions.

Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.

@horseyhorsey Please open a new issue and post us some code, so we can take a look at it. Thanks!

lauxjpn avatar Jun 08 '22 07:06 lauxjpn

Can we close this topic? .Net 5 is already out of support so no use continuing on with this. Better to work on .Net 6/EF Core 6 and EF Core 7 support

ChrisJollyAU avatar Oct 23 '22 17:10 ChrisJollyAU