0

I am trying to make work the simplest project using SQLite.CodeFirst (1.5.1.25, installed from NuGet package) along with the System.Data.SQLite (1.0.108, also NuGet).
However, adding a person will result in

The provider did not return a ProviderManifest instance.

exception. Sadly, there are no official example projects to draw inspiration from, so the following is aggregation of dozens of SO answers gets me following minimal example.
The context:

class Person { [Key] public int ID { get; set; } public string Name { get; set; } } class MyDBContentext : DbContext { public MyDBContentext(string connectionString) : base(new SQLiteConnection() { ConnectionString = connectionString }, true) { } protected override void OnModelCreating(DbModelBuilder modelBuilder) { var sqliteConnectionInitializer = new SqliteCreateDatabaseIfNotExists<MyDBContentext>(modelBuilder); System.Data.Entity.Database.SetInitializer(sqliteConnectionInitializer); } public DbSet<Person> People { get; set; } } //main var conStr = $"Data Source=eftest.sqlite;Version=3;Password=123;"; var ctx = new MyDBContentext(conStr); ctx.People.Add(new Person() { Name = "foo" });//<--- exception throw here var res = ctx.SaveChanges(); 

and the App.config:

 <system.data> <DbProviderFactories> <remove invariant="System.Data.SQLite.EF6" /> <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" /> <remove invariant="System.Data.SQLite" /> <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /> </DbProviderFactories> </system.data> <entityFramework> <providers> <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /> </providers> </entityFramework> 

There is also an inner exception (translated, since it ignores thread culture) if it is of any relevance:

The attempt of method System.Data.SQLite.EF6.SQLiteProviderManifest.GetProviderManifestToken(System.String) to access the method System.Data.SQLite.UnsafeNativeMethods.GetSettingValue(System.String, System.String) failed.

1

2 Answers 2

0

Reinstalling all NuGet packages (SQLite.CodeFirst, System.Data.SQLite and Entity framework) and cleaning the solution resolved the issue.

Sign up to request clarification or add additional context in comments.

Comments

0

For those who are having this issue in the future, delete all SQLite assemblies from your GAC. In my case, I had to run the followings from a command prompt with admin rights:

gacutil –u System.Data.SQLite gacutil –u System.Data.SQLite.Linq 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.