EntityFrameworkCore.Jet
EntityFrameworkCore.Jet copied to clipboard
Unofficial EF Core 6 support
Created to continue discussion on EF core 6 support that was started here
@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
Originally posted by @ChrisJollyAU in https://github.com/bubibubi/EntityFrameworkCore.Jet/issues/98#issuecomment-991045740
@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.
Originally posted by @bairog in https://github.com/bubibubi/EntityFrameworkCore.Jet/issues/98#issuecomment-992162072
You might be missing some references
Need all 3
Originally posted by @ChrisJollyAU in https://github.com/bubibubi/EntityFrameworkCore.Jet/issues/98#issuecomment-992171519
@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?
Originally posted by @bairog in https://github.com/bubibubi/EntityFrameworkCore.Jet/issues/98#issuecomment-992176884
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
Originally posted by @ChrisJollyAU in https://github.com/bubibubi/EntityFrameworkCore.Jet/issues/98#issuecomment-992184759
@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...
Originally posted by @bairog in https://github.com/bubibubi/EntityFrameworkCore.Jet/issues/98#issuecomment-992192402
@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..
Originally posted by @bairog in https://github.com/bubibubi/EntityFrameworkCore.Jet/issues/98#issuecomment-992198687
Actually, might have the same problem on ef6. It is experimental right now. Also perhaps should have a separate issue for ef6 experimental stuff
Originally posted by @ChrisJollyAU in https://github.com/bubibubi/EntityFrameworkCore.Jet/issues/98#issuecomment-992216726
I changed the title to Unofficial EF Core 6 support, since we will not make any official advances towards EF Core 6 until the EF Core 5 supporting release is out.
Cool. @lauxjpn Looks like I have the same problem as you had here https://github.com/dotnet/efcore/issues/26260
Yeah, there are a couple of hiccups when upgrading to 6.0.
@lauxjpn Think I've got it working now. Some things in the JetQuerySqlGenerator I had to comment out. It just uses the base function for now til I have another look at redoing it for the functionality it had without using the sqlexpressionfactory
@bairog If you feel like it give the attached a try. Looks like it works. Have only done 1 test on it though. Just a basic entity query context.Entity.ToList()
. So far it worked and pulled ~40,000 rows without any problems.
ef6.zip
(Standard disclaimer - this is pre-alpha experimental)
@bairog If you feel like it give the attached a try. Looks like it works. Have only done 1 test on it though. Just a basic entity query
context.Entity.ToList()
. So far it worked and pulled ~40,000 rows without any problems. ef6.zip
@ChrisJollyAU I've tested the attached libraries in my console application with .net6.0-windows7.0 TFM. Basic reading with .Where() filtering is working as expected. Many thanks.
I have submitted a pull request that compiles and is based on the v5.0.0-alpha.1 tag with dependencies updated to latest versions & targets .net6.
Any update about the official release for .net6? 5 months ago v5.0.0-alpha.1 is on nuget and it's not compatible with EF 6 (actual 6.0.6).
Version conflict detected for Microsoft.EntityFrameworkCore. Install/reference Microsoft.EntityFrameworkCore 6.0.6 directly to project XXX to resolve this issue. DBMigrations -> Microsoft.EntityFrameworkCore (>= 6.0.6) DBMigrations -> EntityFrameworkCore.Jet 5.0.0-alpha.1 -> Microsoft.EntityFrameworkCore (>= 5.0.14 && < 6.0.0)
Any update on this? Or even .net 5? Microsoft has already ended support for .net 5, maybe you should make LTS versions (.net 6, .net 8) a priority. Wish I could help, but I have no idea how this all works, so I can only count on you guys 😄
I'm trying to make the provider work in .net 6 and there are several changes between frameworks. One big change was in Migration, I think I'm missing something in IDesignTimeServices.
I changed the ConfigureDesignTimeServices method to make it look similar to the one in SQL Server provider, and introduced JetCSharpRuntimeAnnotationCodeGenerator which implements ICSharpRuntimeAnnotationCodeGenerator.
I'm testing with a simple model creating a couple of tables with a primary key and a foreign key, and for some reason when I do an Add-Migration call, it works but misses 2 things in the generated migration class:
1.- Annotation("Jet:Identity", "1, 1") is not added to the primary key in the "columns" property at CreateTable calls (it was being generated correctly on .net 5 provider) 2.- onDelete entry in table.ForeignKey is not generated at all, which also was working well with the .net 5 provider
I wonder if someone knows what I could be missing to handle those 2 items on new services introduced for .net 6 entity framework.
Maybe some developer could guide me to know which class was the responsible of adding those annotations, I think it may be something related with JetAnnotationCodeGenerator, but cannot figure which method is needed to be overriden to make those 2 properties work.
Another usefull info is that if I run the Migration class generated by .net 5 provider using .net 6 build it creates the tables, primary keys (autoincremental) and foreign keys perfectly, which leads me to think that this is only a problem with the Migration class generation/scaffolding.
Any help will be appreciated!
I know there are no plans for .net 6 support untill .net 5 build is out, however maybe it could help to have a .net 6 branch to work on it, since .net 5 is not supported anymore by Microsoft.
@lauxjpn, if you think my contributions may help, you can create a .net 6 support branch and I can make a pull request on this branch with all my changes that doesn't make a full working build at all (like .net 5, not all unit tests are working because lot of them need a redesign), but I think is a good start because it supports basic functionality, and compiles with .net 6.0.8, and maybe someone from the team could help to improve it.
I have got "Disable savepoint API, because it is not supported by Jet" issue while using EFCore.Jet.NET6 codebase.
In general (on first glance, after a few tests with sample Nortwind database) EFCore.Jet.NET6 seems to be working rather well. It would be helpful to have EF Core 5 and EF Core 6 merged with EF Core 6 becoming the main codebase.
I have got "Disable savepoint API, because it is not supported by Jet" issue while using EFCore.Jet.NET6 codebase.
In general (on first glance, after a few tests with sample Nortwind database) EFCore.Jet.NET6 seems to be working rather well. It would be helpful to have EF Core 5 and EF Core 6 merged with EF Core 6 becoming the main codebase.
Which repo are you using? https://github.com/ChrisJollyAU/EntityFrameworkCore.Jet/tree/net6 ?
@ShamilS @nicovil That issue and fix was after my experimental build. I should probably look at merging all the fixes since then and produce a new build
@ShamilS @nicovil That issue and fix was after my experimental build. I should probably look at merging all the fixes since then and produce a new build
@ChrisJollyAU That would be great! Also for what I saw in your repo the dependencies (Dependencies.targets) are for .net 6.0.0, and we're now in .net 6.0.9, so maybe this needs an update.
I have y working copy updated to latest packages for 6.0.9
I have got "Disable savepoint API, because it is not supported by Jet" issue while using EFCore.Jet.NET6 codebase. In general (on first glance, after a few tests with sample Nortwind database) EFCore.Jet.NET6 seems to be working rather well. It would be helpful to have EF Core 5 and EF Core 6 merged with EF Core 6 becoming the main codebase.
Which repo are you using? https://github.com/ChrisJollyAU/EntityFrameworkCore.Jet/tree/net6 ?
@nicovil I have just checked - downloaded .zip archive from https://github.com/ChrisJollyAU/EntityFrameworkCore.Jet/tree/net6. Is it correct? I still have the subject error when using transactions.
@ShamilS @nicovil That issue and fix was after my experimental build. I should probably look at merging all the fixes since then and produce a new build
@ ChrisJollyAU It would be great! I'd be waiting for your fixes!
@ShamilS @nicovil That issue and fix was after my experimental build. I should probably look at merging all the fixes since then and produce a new build
@ChrisJollyAU That would be great! Also for what I saw in your repo the dependencies (Dependencies.targets) are for .net 6.0.0, and we're now in .net 6.0.9, so maybe this needs an update.
I have y working copy updated to latest packages for 6.0.9
@nicovil @ChrisJollyAU Yes, net 6.0.9 as the target .NET (Core) version would be the best option.
Here is a short wish list for EFCore.NET.6.0.9+:
-
.IsClustered(...) fluent API call is not supported and has to be commented out, e.g.
entity.HasKey(e => e.Id) .HasName("Category_PK") ; // .IsClustered(false);
It would be useful if .IsClustered(...) fluent API call would be just ignored by EFCore.JET6.
-
.HasColumnType("image") fluent API is not suported and results in runtime error,
Data type 'image' for property 'Picture' is not supported in this form. Either specify the length explicitly in the type name, for example as 'image(16)', or remove the data type and use APIs such as HasMaxLength to allow EF choose the data type.
so it currently has to be commented out:
For example:
entity.Property(e => e.Picture)
//.HasColumnType("image")
.HasComment("A picture representing the food category.");
Images are (usually) stored in MS Access files with 'OLE Object/Long Binary Data' data type.
-
MS Access Binary data type's data corresponding to byte[] type in C# Entity classes and originated from Timestamp data type in MS SQL database
public byte[]? RowTimeStamp { get; set; }
is not properly loaded when DbContext's OnModelCreating() method used .IsRowVersion() and .IsConcurrencyToken() API calls, e.g:
entity.Property(e => e.RowTimeStamp)
.IsRowVersion()
.IsConcurrencyToken();
when .IsRowVersion() and .IsConcurrencyToken() are commented out then data is properly loaded and saved to MS Access database.
entity.Property(e => e.RowTimeStamp)
//.IsRowVersion()
//.IsConcurrencyToken()
;
-
It would be also useful to have
SET IDENTITY_INSERT ...
raw sql call, e.g.,ctx.Database.ExecuteSqlRaw($"SET IDENTITY_INSERT [{entityName}] OFF");
to be ignored by EFCore.Jet.6.0.9+ to have the same DbContext code working with MS Access and MS SQL backends without conditional compilation or run-time backend-type checks to bypass code not supported by certain backend types.
@nicovil @ShamilS I've had a look and have updated to 6.0.9 (although if your project was directly referencing 6.0.9 it would be using that as what it is compiled against is set as the minimum required version). I've also merged the fixes from the master branch into my code.
I will note that I haven't gotten to any tests yet. All I know is that it compiles without errors. Will probably be able to do some stuff tomorrow/this week EntityFrameworkCore.Jet.zip
Also, @ShamilS I will see if there is anything I can do about your points. Some will be easier than others
@nicovil @ShamilS I've had a look and have updated to 6.0.9 (although if your project was directly referencing 6.0.9 it would be using that as what it is compiled against is set as the minimum required version). I've also merged the fixes from the master branch into my code.
I will note that I haven't gotten to any tests yet. All I know is that it compiles without errors. Will probably be able to do some stuff tomorrow/this week EntityFrameworkCore.Jet.zip
Also, @ShamilS I will see if there is anything I can do about your points. Some will be easier than others
@ChrisJollyAU Transactions work now. Thanks!
@ChrisJollyAU: Do you plan to release the sources of the EntityFrameworkCore.Jet (6.0.x) in the near future? I may try to help with correction of its tests code etc. It's more suitable to write sample and production apps when the whole source code base of the EntityFrameworkCore.Jet is available, as this source code allows to debug/trace problematic use-cases and formulate change-requests or even post PRs.
Thank you again for your quick and so effective fix of the current version of the EntityFrameworkCore.Jet .
@ShamilS Pretty sure it's been mentioned here somewhere, but all my current stuff on net6 is found here https://github.com/ChrisJollyAU/EntityFrameworkCore.Jet/tree/net6
@ChrisJollyAU OK, my fault, I missed to mention specific branch in git clone - it should have been:
git clone --branch net6 https://github.com/ChrisJollyAU/EntityFrameworkCore.Jet.git
Thanks!