I am using Entity Framework 4 code first method to automatically create SQLite database, I get an error telling me ProviderIncompatibleException:
我正在使用Entity Framework 4 code first方法自动创建SQLite数据库,我收到一个错误信息,告诉我ProviderIncompatibleException:
[System.Data.ProviderIncompatibleException] = {"CreateDatabase is not supported by the provider."}
I thaught EF 4 support it?
我是否支持它?
I am using this in app.config:
我正在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.
谢谢你!
3 个解决方案
#1
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.
支持代码优先(您提到的CreateDatabase()方法)和代码优先迁移(代码优先开发的更新方法)都是在某个EF-provider级别实现的。System.Data。SQLite所有这些功能都没有在提供程序中实现。如果需要,应该使用其他ef -provider。例如,SQLite的Devart dotConnect支持代码优先和代码优先的迁移。
Devart Team
Devart团队
#2
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.
这通常是由于。net 2 agaisnt和。net 4之间的兼容性问题引起的。
Take a look at this link, it should give you the answer: system.data.sqlite .net 4
看看这个链接,它应该给你答案: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).
注意,您必须在应用程序.config或web中应用此功能。配置您的模型的位置,但也在您的entrypoint项目中(例如,您的.exe,或asp.net项目)。
#3
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.
@Kev菲克斯:如果您正在使用SQLite提供者从https://system.data.sqlite.org/,那么它不支持迁移(如创建数据库)。您可以使用一个商业版本(比如Devart),也可以编写自己的迁移。本文使用Android的概念来制定一个简单的迁移策略http://hintdesk.com/sqlite-with- entityframework- code first-and-migration/。如果对你有帮助的话,看看。
#1
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.
支持代码优先(您提到的CreateDatabase()方法)和代码优先迁移(代码优先开发的更新方法)都是在某个EF-provider级别实现的。System.Data。SQLite所有这些功能都没有在提供程序中实现。如果需要,应该使用其他ef -provider。例如,SQLite的Devart dotConnect支持代码优先和代码优先的迁移。
Devart Team
Devart团队
#2
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.
这通常是由于。net 2 agaisnt和。net 4之间的兼容性问题引起的。
Take a look at this link, it should give you the answer: system.data.sqlite .net 4
看看这个链接,它应该给你答案: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).
注意,您必须在应用程序.config或web中应用此功能。配置您的模型的位置,但也在您的entrypoint项目中(例如,您的.exe,或asp.net项目)。
#3
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.
@Kev菲克斯:如果您正在使用SQLite提供者从https://system.data.sqlite.org/,那么它不支持迁移(如创建数据库)。您可以使用一个商业版本(比如Devart),也可以编写自己的迁移。本文使用Android的概念来制定一个简单的迁移策略http://hintdesk.com/sqlite-with- entityframework- code first-and-migration/。如果对你有帮助的话,看看。