10

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.

Thanks a lot.

EDIT:

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

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>

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

1
  • Could you solve your problem already? Commented May 23, 2011 at 10:26

2 Answers 2

6

You need to use the assembly qualified name:

<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" />
Sign up to request clarification or add additional context in comments.

1 Comment

And the connection string?
5

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

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.

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.