2014-02-14 68 views
11

我試圖創建一個簡單的項目,使用SQLite數據庫提供商的作品首次探討如何實體框架6的代碼,但是當我complite我的應用程序出現錯誤:你如何使Entity框架6 + Sqlite +代碼首先工作?

"The Entity Framework provider type 'System.Data.SQLite.SQLiteProviderServices, System.Data.SQLite.Linq, Version=1.0.91.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SQLite' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information."

我認爲,這個錯誤有某事使用app.config文件。 有沒有人有一個工作的實體框架6 + Sqlite 1.0.91 app.config文件?

這是我的配置文件的內容:

<?xml version="1.0"?> 
<configuration> 
    <configSections> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    </configSections> 

    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/> 
    <providers> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/> 
     <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.SQLiteProviderServices, System.Data.SQLite.Linq, Version=1.0.91.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139"/> 
    </providers> 
    </entityFramework> 
    <connectionStrings> 
    <add name="BloggingContext" connectionString="Data Source=.\animals.sqlite" providerName="System.Data.SQLite"/> 
    </connectionStrings> 
    <system.data> 
    <DbProviderFactories> 
     <remove invariant="System.Data.SQLite"/> 
     <add name="SQLite Data Provider" invariant="System.Data.SQLite" description="Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite"/> 
    </DbProviderFactories> 
    </system.data> 


<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration> 
+0

相關:http://stackoverflow.com/questions/22174212/entity-framework-6-with-sqlite-3-code-first-wont-create-tables –

回答

2

首先請從供應商部分的下面一行:

<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.SQLiteProviderServices, System.Data.SQLite.Linq, Version=1.0.91.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139"/> 

並添加如下行,而不是說:

<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.SQLiteProviderServices, System.Data.SQLite.Linq" /> 

欲瞭解更多信息:Problems using Entity Framework 6 and SQLite

+1

謝謝Sampath,我做了改變,但我做了仍然收到相同的錯誤信息。該項目在這裏:http://www.sendspace.com/file/ovdxly –

+0

@YiannisMpourkelis請檢查此鏈接:https://github.com/Aimeast/GitCandy/issues/3 – Sampath

+0

此鏈接不適用於一樣的問題。不過,我嘗試了一些在那裏討論的事情,但沒有成功。如果有人擁有一個簡單的工作控制檯或WPF應用程序,首先使用SQLite 1.0.91代碼,並上傳它將有助於 –

相關問題