System.Data.SQLite

Login
This project makes use of Eagle, provided by Mistachkin Systems.
Eagle: Secure Software Automation
Ticket Hash: ad28d8e026c4c2275547a58bac3fe426ead63faa
Title: System.Data.Entity.Core.ProviderIncompatibleException on netcore3 (using EF 6.3)
Status: Closed Type: Code_Defect
Severity: Important Priority: Medium
Subsystem: Connection Resolution: Fixed
Last Modified: 2020-04-20 08:36:50
Version Found In: 1.0.112
User Comments:
anonymous added on 2019-10-29 17:18:29:
When using dbContext.Database.ExecuteSqlCommand or dbContext.Database.SqlQuery<T> the call just fails with the following stacktrace.

The same code works when targeting net48 (instead of netcoreapp3.0) or when using 1.0.111 (and ignoring the NuGet-restore warnings).

System.Data.Entity.Core.ProviderIncompatibleException
  HResult=0x80131920
  Message=A null was returned after calling the 'get_ProviderFactory' method on a store provider instance of type 'System.Data.SQLite.SQLiteConnection'. The store provider might not be functioning correctly.
  Source=EntityFramework
  StackTrace:
   at System.Data.Entity.Core.Common.DbProviderServices.GetProviderFactory(DbConnection connection)
   at System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInvariantName(DbConnection connection)
   at System.Data.Entity.Internal.InternalConnection.get_ProviderName()
   at System.Data.Entity.Internal.LazyInternalContext.get_ProviderName()
   at System.Data.Entity.Internal.DefaultModelCacheKeyFactory.Create(DbContext context)
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.Initialize()
   at System.Data.Entity.Internal.InternalContext.ExecuteSqlCommand(TransactionalBehavior transactionalBehavior, String sql, Object[] parameters)
   at System.Data.Entity.Database.ExecuteSqlCommand(TransactionalBehavior transactionalBehavior, String sql, Object[] parameters)
   at System.Data.Entity.Database.ExecuteSqlCommand(String sql, Object[] parameters)

mistachkin added on 2019-10-30 00:42:20:
Please try adding the following line of code to your application and see if
the issue is still present:

Environment.SetEnvironmentVariable("TypeName_SQLiteProviderServices",
"System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6, " +
"Version=1.0.112.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139");

anonymous added on 2019-10-30 08:41:44:
I'm sorry but this did not change anything -- still the very same error message.

anonymous added on 2019-10-30 12:42:14:
I attached a sample to reproduce the exception.

mistachkin added on 2019-10-30 16:04:24:
Thanks for the example.  I'll investigate this issue as soon as I can.

anonymous added on 2019-10-30 18:28:39:
Hello, OT here again (the one with the attachment at 2019-10-30 12:42:14 was a different person),

I wanted to note that years ago I got rid of all magic tokens inside app.config or .edmx files (meanwhile migrated to code first) by doing two things:

1) The class inheriting from DbContext only uses the ctor which passes in a read DbConnection instance. In my case this can be SQLServer or SQLite, determined at runtime by user settings.

2) There is one configuration class inside the same assembly inheriting from System.Data.Entity.DbConfiguration and doing the following inside the ctor:

	this.SetProviderFactory("System.Data.SQLite", System.Data.SQLite.SQLiteFactory.Instance);
	var providerServices = GetService<System.Data.Entity.Core.Common.DbProviderServices>(System.Data.SQLite.EF6.SQLiteProviderFactory.Instance);
	Debug.Assert(providerServices != null, "providerServices != null");
			this.SetProviderServices("System.Data.SQLite", providerServices);

Why and how this works I figured out using Reflection years ago. Might be outdated.

anonymous added on 2019-12-06 12:04:48:

Still same problem with netcore3.1 + EF 6.4.

Is this already fixed for 113 (or will there be a patch release)?


mistachkin added on 2019-12-08 03:29:02:

I've determined the root cause of this issue. The System.Data.SQLite assembly built for .NET Standard 2.1 is missing the two partial class files from the "LINQ" sub-directory, due to incorrect conditional compilation.

This issue will be fixed for the 1.0.113.0 release.


mistachkin added on 2019-12-08 04:02:27:

Fixed on trunk via check-in [6b6fb5374d].


anonymous added on 2020-04-16 12:44:55:

In which 1.0.112.1 nuget packge are these missing partials? or should be?


mistachkin added on 2020-04-18 13:11:18:

The issue should be resolved in the 1.0.112.1 NuGet packages.


anonymous added on 2020-04-20 08:36:50:

Which 1.0.112.1 one? .EF6, .LINQ, .Core, .MSIL? There is no "System.Data.SQLite 1.0.112.1" at all.