12

I am trying to create a simple project to explore how Entity framework 6 code first with sqlite db provider works, but when I complite my app I get the error:

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

I think that this error has something to do with the app.config file. Does anyone has a working app.config file for Entity framework 6 + Sqlite 1.0.91?

These are my config file contents:

    <?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>
Sampath
  • 63,341
  • 64
  • 307
  • 441
Yiannis Mpourkelis
  • 1,366
  • 1
  • 15
  • 34
  • related: http://stackoverflow.com/questions/22174212/entity-framework-6-with-sqlite-3-code-first-wont-create-tables – CAD bloke Mar 02 '16 at 12:05

2 Answers2

2

Firstly remove the below line from the providers section :

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

And add below line instead of that :

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

For more info : Problems using Entity Framework 6 and SQLite

Community
  • 1
  • 1
Sampath
  • 63,341
  • 64
  • 307
  • 441
  • 1
    Thank you Sampath, I made the changes but I am still getting the same error message. The project in question is here: http://www.sendspace.com/file/ovdxly – Yiannis Mpourkelis Feb 14 '14 at 13:51
  • @YiannisMpourkelis Please check this link also :https://github.com/Aimeast/GitCandy/issues/3 – Sampath Feb 14 '14 at 13:57
  • This link is not for the same problem. However I tried some of the things discussed there but without success. If someone has a simple working console or WPF app with working SQLite 1.0.91 code first and upload it will help – Yiannis Mpourkelis Feb 15 '14 at 12:58
  • Looks like there are same problem. – Aimeast Mar 16 '14 at 02:43
1

There is a good article for this issue: http://hintdesk.com/sqlite-with-entity-framework-code-first-and-migration/

After reading it my consolusion is: "No, please do not use sqlite if you want EF + code first". Use SQL CE instead even though it's deprecating.

Xinan
  • 3,002
  • 1
  • 16
  • 18