Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework 4 does not support SQLite

I am using Entity Framework 4 code first method to automatically create SQLite database, I get an error telling me ProviderIncompatibleException:

[System.Data.ProviderIncompatibleException] = {"CreateDatabase is not supported by the provider."}

I thaught EF 4 support it?

I am using this in app.config:

<system.data>
    <DbProviderFactories>
      <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, Version=1.0.81.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
    </DbProviderFactories>
  </system.data>

Thank you.

like image 982
Alvin Avatar asked Jan 01 '26 03:01

Alvin


2 Answers

Support of both Code-First ( the CreateDatabase() method you mentioned) and Code-First Migrations (a newer approach to Code-First development) is implemented at the level of a certain EF-provider. In case of System.Data.SQLite all this functionality is not implemented in the provider. If you need it, you should use other EF-providers. For example, Devart dotConnect for SQLite supports both Code-First and Code-First Migrations.

Devart Team

like image 162
Devart Avatar answered Jan 02 '26 17:01

Devart


It's often caused by compatibility issue between .NET 2 agaisnt which SQLite data provider was built and .NET 4 you are actually using.

Take a look at this link, it should give you the answer: system.data.sqlite .net 4

Note that you have to apply this in your app.config or web.config where your model is located but also in your entrypoint project (your .exe, or asp.net project for example).

like image 32
Guillaume Avatar answered Jan 02 '26 17:01

Guillaume



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!