ErikEJ / EFCorePowerTools

Entity Framework Core Power Tools - reverse engineering, migrations and model visualization in Visual Studio & CLI
MIT License
2.12k stars 293 forks source link

[SQLite] Reverse Engineer database error #663

Closed mohaaron closed 3 years ago

mohaaron commented 3 years ago

I am trying to reverse engineer a SQLite database in a class library project that is part of a WPF application. I am running the reverse engineer on the class library project and when creating a new connection to my SQLite database file I am getting the following error.

Could not load file or assembly 'System.Data.SQLite, Version=1.0.113.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

It looks to me like I need to use System.Data.Sqlite 1.0.113.0 for the versions to match, but it's not available on Nuget. I downloaded it from https://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki and manually installed it, but it didn't fix the error.

Steps to reproduce

Further technical details

EF Core Power Tools version: (found in About dialog - blue questionmark icon on context menu)

SQLite ADO.NET Provider included: 1.0.109.0 SQLite EF6 DbProvider in GAC - Yes

System.Data.SQLite DDEX provider - No SQLite Simple DDEX provider - Yes

SQL Server Compact 4.0 in GAC - No SQL Server Compact 4.0 DbProvider - No

SQL Server Compact 4.0 DDEX provider - No SQL Server Compact 4.0 Simple DDEX provider - Yes

SQL Server Compact 3.5 in GAC - No SQL Server Compact 3.5 DbProvider - No

SQL Server Compact 3.5 DDEX provider - No

Sync Framework 2.1 SqlCe 3.5 provider - No

SQLite ADO.NET Provider included: 1.0.109.0 SQLite EF6 DbProvider in GAC - Yes System.Data.SQLite DDEX provider - No SQLite Simple DDEX provider - Yes

<system.data>
<DbProviderFactories> 
    <add name="SQLite Data Provider" 
         invariant="System.Data.SQLite.EF6" 
         description=".NET Framework Data Provider for SQLite" 
         type="System.Data.SQLite.EF6.SQLiteProviderFactory, 
                System.Data.SQLite.EF6, 
                Version=1.0.113.0, 
                Culture=neutral, 
                PublicKeyToken=db937bc2d44ff139" 
    />  
</DbProviderFactories> 
</system.data>

Database engine: (SQlite, SQL Compact, SQL Server, Postgres) SQLite

Visual Studio version: (e.g. Visual Studio 2017 15.7) Visual Studio 2019 Version 16.8.3

ErikEJ commented 3 years ago

Look at and carefully follow the instructions here: https://github.com/ErikEJ/SqlCeToolbox/wiki/EF6-workflow-with-SQLite-DDEX-provider (install the x86 package, not the x64 one, for example!)

mohaaron commented 3 years ago

Hi Erik,

I have uninstalled the x64 version and installed sqlite-netFx46-setup-bundle-x86-2015-1.0.113.0.exe now. I still see that SQLite/Compact Toolbox and EF Core PowerTools show System.Data.SQLite DDEX provider - No in their help screen. I also can only find the nugget package System.Data.SQLite version 1.0.113.6. The only nuget package in version 1.0.113.0 that I see is System.Data.SQLite.EF6.

I'm not sure what I'm doing wrong.

ErikEJ commented 3 years ago

Based on past experience, you are not following caarefully all the steps in the guide (sorry, I did not create the Sqlite VS tools)

mohaaron commented 3 years ago

Erik,

The directions (https://github.com/ErikEJ/SqlCeToolbox/wiki/EF6-workflow-with-SQLite-DDEX-provider#install-sqlite-in-gac) don't say if the System.Data.SQLite DDEX provider - No in the help screen needs to say Yes. Can you clarify if this value needs to be Yes for the SQLite connection for reverse engineer to work? The functions of the SQLite/Compact Toolbox all work without issue.

ErikEJ commented 3 years ago

Yes, the DDEX provider must be installed.

mohaaron commented 3 years ago

Thank you for your help.

ErikEJ commented 3 years ago

You are welcome, sorry that connecting to SQLite is so complicated.

ErikEJ commented 3 years ago

With the latest daily build, you can avoid installing the provider!