linq2db / linq2db.EntityFrameworkCore

Bring power of Linq To DB to Entity Framework Core projects
MIT License
462 stars 38 forks source link

MissingMethodException: LinqToDB.DataProvider.Oracle.OracleTools.GetDataProvider() #294

Closed jkrajcir closed 1 year ago

jkrajcir commented 1 year ago

Nuget packages being used:

I am running the following code: LinqToDBForEFTools.Initialize(); await using IDbContextTransaction transaction = await DbContext.Database.BeginTransactionAsync(); using IDataContext linqToDbContext = DbContext.CreateLinqToDbContext(transaction);

Calling DbContext.CreateLinqToDbContext(transaction) throws the following exception: Unhandled exception. System.MissingMethodException: Method not found: 'LinqToDB.DataProvider.IDataProvider LinqToDB.DataProvider.Oracle.OracleTools.GetDataProvider(LinqToDB.DataProvider.Oracle.OracleVersion, LinqToDB.DataProvider.Oracle.OracleProvider)'. at LinqToDB.EntityFrameworkCore.LinqToDBForEFToolsImplDefault.CreateLinqToDbDataProvider(EFProviderInfo providerInfo, LinqToDBProviderInfo provInfo, EFConnectionInfo connectionInfo) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at LinqToDB.EntityFrameworkCore.LinqToDBForEFTools.GetDataProvider(EFProviderInfo info, EFConnectionInfo connectionInfo) at LinqToDB.EntityFrameworkCore.LinqToDBForEFTools.CreateLinqToDbContext(DbContext context, IDbContextTransaction transaction)

Using linq2db v4.4.1 works fine and doesn't throw this exception.

Looks like ProviderName is getting set to one of the Oracle ones somehow, which calls the wrong method here

jkrajcir commented 1 year ago

I downloaded the v6.11.0 code to see what is going on in with the debugger, and it looks like ProviderName is getting correctly set to "SqlServer". CreateLinqToDbDataProvider() is where the exception is getting thrown. The debugger won't let me step in further, and won't hit a breakpoint set inside the method.

jkrajcir commented 1 year ago

Changed linq2db back to 4.4.1 and was able to use linqToDbContext.GetFluentMappingBuilder() to configure the mapping of the nullable property that was giving me problems.

This issue can be closed since I ultimately fixed the problem I was running into. I suspect #293 will probably fix this anyways.

Thank you for this useful library!

sdanyliv commented 1 year ago

Yes, you cannot use version 5.0 preview with this extension. It is just incompatible yet.

MaceWindu commented 1 year ago

linq2db 5.0.0 support released