3

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.

1

3 Answers 3

3

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

1
  • 1
    @KevFixx The free, standard edition of dotConnect for SQLite does not support EF at all. The professional edition supports EF including both Code First and Migrations.
    – bricelam
    Oct 15, 2012 at 16:21
1

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).

0

@Kev Fixx: If you're using SQLite provider from https://system.data.sqlite.org/‎, then it doesn't support Migrations (such as Create Database). You can use a commercial one (like from Devart) or you write your own Migration. This article uses the concept from Android to make a simple Migration strategy http://hintdesk.com/sqlite-with-entity-framework-code-first-and-migration/ . Take a look if it helps you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.