EF Code First and SQLite

code-first entity entity-framework sqlite

Question

I'm thrilled to utilize SQLite for testing with Entity Framework Code First after having experience with NHibernate and SQLite.

It would be nice and save some time from my busy day if you have some sample connections string and setup examples.

You're welcome.

EDIT:

It's important to note that I get the following problem while using the EF "data context" to perform crud operations when debugging:

'System.Data.SQLite.SQLiteConnection' connection's provider name cannot be determined.

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

Hopefully, EF and SQLite do combine in this way. Despite the error message's scary suggestion that it's unlikely.

1
10
12/14/2010 9:03:23 AM

Accepted Answer

Any ADO.NET 3.5 level service should have no trouble integrating with Code First (these implement Entity Framework functionality).

Additionally, the 4.0 competent providers include functionality for DeleteDatabase, CreateDatabase, and DatabaseExists.

Beyond this, Code First does not need any more provider capability.

In order to generate everything else it requires, it first looks at the type of the Connection and then attempts to map it back to the provider and its provider factory.

It would be prudent to confirm that your GAC is home to an updated SQLLite supplier that supports the 3.5 level capability.

5
10/24/2017 4:08:47 PM

Popular Answer

The assembly qualified name must be used:

<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.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow