Entity Developer, Microsoft SQLite Driver, You need to call SQLitePCL.raw.SetProvider()

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
berj
Posts: 3
Joined: Wed 10 Mar 2021 12:47

Entity Developer, Microsoft SQLite Driver, You need to call SQLitePCL.raw.SetProvider()

Post by berj » Wed 10 Mar 2021 13:03

I would like to use the Entity Developer in a Core 5.0 console app along with Microsoft.Data.SQLite drivers.
When I try to add a Devart EF Core Model I have to address the database(file) to be handled.
So far so easy.
When I then click to check database connection I get the followin error message: "You need to call SQLitePCL.raw.SetProvider(). If you are using a bundle package, this is done by calling SQLitePCL.Batteries.Init()".
Does this mean I have to use the Devart dotConnect for SQLite in any case or is there any possibility to also use the Mircrosoft SQLite items.
This is new for me - have up to now only handled .Net Framework and Entity Developer.
I will be very curious for any answer!
Greetings
Jochen

Shalex
Site Admin
Posts: 9305
Joined: Thu 14 Aug 2008 12:44

Re: Entity Developer, Microsoft SQLite Driver, You need to call SQLitePCL.raw.SetProvider()

Post by Shalex » Fri 12 Mar 2021 18:21

1. Please run the following commands in Package Manager Console of your .NET 5 project:

Code: Select all

PM> install-package system.data.sqlite
PM> uninstall-package system.data.sqlite
PM> install-package microsoft.entityframeworkcore.sqlite
JIC: system.data.sqlite is loaded from local NuGet cache and used for design-time features of Entity Developer, but the EF Core code will be generated for microsoft.entityframeworkcore.sqlite

2. Run Create Model Wizard of Devart EF Core Model and choose "Microsoft SQLite Data Provider".

berj
Posts: 3
Joined: Wed 10 Mar 2021 12:47

Re: Entity Developer, Microsoft SQLite Driver, You need to call SQLitePCL.raw.SetProvider()

Post by berj » Sat 13 Mar 2021 10:18

Shalex, thank you very much for your reply - but, it didn't help ...
Honestly I have to tell that I wanted to start a "Database first" job.
So I created a new project, followed your advices and added a Devart EF Core Model. After that I was asked for the database provider (which I already had after installing "Microsoft.EntityFrameworkCore.Sqlite.Core". After that I provided the location of the SQLite database file.
Next step was then to check the database connection - but: same error message than before.
So I was not able to run the model creator ...

Any other suggestions?

Shalex
Site Admin
Posts: 9305
Joined: Thu 14 Aug 2008 12:44

Re: Entity Developer, Microsoft SQLite Driver, You need to call SQLitePCL.raw.SetProvider()

Post by Shalex » Mon 15 Mar 2021 18:52

1. You chose "Microsoft SQLite Data Provider" in Create Model Wizard of Devart EF Core Model, didn't you?

2. When the error occurs, run the 2nd instance of Visual Studio, navigate to Debug > Attach to Process and attach to the first VS (where you launched Create Model Wizard). Then, open Debug > Windows > Modules. Is System.Data.SQLite.dll loaded in the process? If yes, specify its full path.

3. As a workaround, try using a standalone Entity Developer.

berj
Posts: 3
Joined: Wed 10 Mar 2021 12:47

Re: Entity Developer, Microsoft SQLite Driver, You need to call SQLitePCL.raw.SetProvider()

Post by berj » Wed 17 Mar 2021 08:19

It works!
I simply let "System.Data.SQLite" stay in the project w/o deleting it!
After that the createion of the model using Entity Developer is possible. At the end of this process "Microsoft.EntityFrameworkCore.Sqlite.Core" is installed (by Entity Developer)
Not clear is whether data can be read an write because of my lack in time to chack that already - but indeed this shall work!
Thank you very much for your hints, Shalex.
Greetings, Jochen!

Post Reply