0

I am attempting to change the database provider for a project that uses Entity Framework 6.4.4 from SQL Server to SQLite.

I have the SQLite nuget package installed on the project as well as the SQLite toolbox extension for VS2022. The project already has an .edmx file describing the database I would like to build. However, when I attempt to generate the database (via the Generate Database Wizard), SQLite is not available as a Data Source:

Change Data Source Image

I have read some posts about this issue and many advise installing the packages found here: https://system.data.sqlite.org/index.html/doc/trunk/www/news.wiki

However, these packages do not include Visual Studio 2022, nor do they include .NET Framework 4.8.

I am able to create and manage SQLite databases via the SQLite Toolbox extension, but that functionality does not extend to the DB Creation Wizard.

My app.config is shown below. This should be looking for SQLite as a DB provider. I've made sundry edits to this file to no effect.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
    
        <section name="entityFramework" 
                 type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral,  PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </configSections>
    <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
        <providers>
            <provider invariantName="System.Data.SQLite" 
                      type="System.Data.SQLite.SQLiteProviderServices, System.Data.SQLite" />
        </providers>
    </entityFramework>
    <connectionStrings>
        <add name="PSRtestDB.db"
             connectionString="data source=C:\Users\adamsc\Documents\TEMP\PSR DB\PSRtestDB.db"
             providerName="System.Data.SQLite" />
    </connectionStrings>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
    </startup>
</configuration>

The question below appears to imply that this simply can't be done, that the DB must be created manually if SQLite is to be used. I would appreciate confirmation on that from anyone who has experience in this area.

Entity Framework 6 not creating tables in SQLite database

I am stymied and unsure what to try. Does anyone have any suggestions? Thanks in advance.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
acs676
  • 1
  • I have som advise here: https://github.com/ErikEJ/SqlCeToolbox/wiki/EF6-workflow-with-SQLite-DDEX-provider – ErikEJ Jul 27 '23 at 05:11
  • @ErikEJ, thank you for the post. The link included steps that I had not previously tried. Unfortunately, while I did get the SQLite EF6 provider in the GAC and install all necessary packages, the provider still is not an option to connect to a new database. It seems like if the tool registers as available in one place it ought to be available elsewhere. Any ideas of where to look for errors? Thank you. – acs676 Jul 27 '23 at 19:46

0 Answers0