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.
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
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).
@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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.