优先使用EF代码的SQLite [英] SQLite with EF Code First

查看:186
本文介绍了优先使用EF代码的SQLite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将SQLite与NHibernate结合使用成功后,我非常高兴将其用于Entity Framework Code First的测试。

After my success using SQLite with NHibernate, I am very happy to use it for testing with Entity Framework Code First.

如果您有一些示例连接字符串并进行了设置演示,那会很棒,并且可以从忙碌的一天中节省一些时间。

If you have some example connections string and set up demos, that would be great and save a bit of time from my hectic day.

非常感谢。

编辑:

值得一提的是,在通过EF数据上下文应用Crud操作时,调试时出现此错误:

Worth mentioning that I am getting this error during debugging when applying crud actions via the EF "data context":

无法确定类型为'System.Data.SQLite.SQLiteConnection'的连接的提供程序名称。

Unable to determine the provider name for connection of type 'System.Data.SQLite.SQLiteConnection'.

<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" />
    </DbProviderFactories>
</system.data>


<connectionStrings>
    <add name="DataContext"
         connectionString="Data Source=:memory:;Version=3;New=True;"
         providerName="System.Data.SQLite"
     />
</connectionStrings>

希望EF确实以这种方式与SQLite集成。

Hopefully EF does integrate with SQLite in this fashion. Although the error message, alarmingly, suggests probably not.

推荐答案

Code First应该可以在任何ADO.NET 3.5级别的提供程序中正常工作。 (这些实现Entity Framework功能)。

Code First should work just fine with any ADO.NET 3.5 level provider (these implement Entity Framework functionality).

具有4.0功能的提供程序还添加DeleteDatabase / CreateDatabase / DatabaseExists功能。

The 4.0 capable providers also add DeleteDatabase/CreateDatabase/DatabaseExists functionality.

代码优先除这些功能外不需要任何其他提供程序功能。

Code First requires no additional provider functionality beyond these.

发生的事情是,它查看连接的类型,然后尝试将其映射回提供程序及其状态。提供程序工厂,以便它可以创建它需要的其他所有内容。

What happens is that it looks at the type of the Connection and then tries to map that back to the provider and its provider factory so it can create everything else it needs.

值得检查一下,以确保在GAC中安装了最新的SQLLite提供程序来支持3.5级功能。

It would be worth checking to make sure you have an up-to-date SQLLite provider installed in your GAC that supports the 3.5 level functionality.

这篇关于优先使用EF代码的SQLite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆