0

I have followed very closely this great tutorial about how to connect SQLite with Visual Studio 2013, but when I get to the Entity Data Model Wizard part of the tutorial, I can't see my SQLite connection or the SQLite provider, there are only options for the SQL Server.

I have followed the tutorial very closely, I even tried to install the SQL Server Compact/SQLite Toolbox, to compile the project to x86, to install the Entity Framework Visual Studio tools, and still nothing happens.

My packages.config looks like:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="CommonServiceLocator" version="1.2" targetFramework="net45" />
  <package id="EntityFramework" version="6.1.2" targetFramework="net45" />
  <package id="NodaTime" version="1.3.0" targetFramework="net45" />
  <package id="Prism" version="5.0.0" targetFramework="net45" />
  <package id="Prism.Composition" version="5.0.0" targetFramework="net45" />
  <package id="Prism.Interactivity" version="5.0.0" targetFramework="net45" />
  <package id="Prism.Mvvm" version="1.0.0" targetFramework="net45" />
  <package id="Prism.PubSubEvents" version="1.0.0" targetFramework="net45" />
  <package id="System.Data.SQLite.Core" version="1.0.94.0" targetFramework="net45" />
  <package id="System.Data.SQLite.EF6" version="1.0.94.0" targetFramework="net45" />
</packages>

any advices on this?


EDIT 1:

I am kinda shifting to SQL Server CE 4.0, even though it's being deprecated. I rather SQLite for lack of 4Gb limitation, but I can't make it work, and I have read EF isn't smoothly integrated on it.

But now I have a new problem, this arises both with SQL Server CE 4 and MySQL:

Error for EF 6.1.2

I hate to be stuck in a project for such little things like this, anyone knows how to solve this?

Michel Feinstein
  • 13,416
  • 16
  • 91
  • 173

4 Answers4

2

I ran into this exact problem this morning (I was following the blog post you referenced in your original problem) and I found the issue, and how to resolve it:

  1. Uninstall the nuget package for SqlLite EF6
  2. Remove the system.data entries from the app.config
  3. Install the nuget package
  4. Only put the two removes and one add in your app.config

    <DbProviderFactories>
      <remove invariant="System.Data.SQLite" />
      <remove invariant="System.Data.SQLite.EF6" />
      <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
    

  5. Now the SQLLite will show up in the ADO.NET Entity Data Model connection area

You may need to add the second "add" back into the system.data for it to work at runtime since I haven't gotten that far yet.

TomEddie
  • 23
  • 4
0

Have you got ONLY the 1.0.94 SQLite VS Tools installed in GAC?

ErikEJ
  • 40,951
  • 5
  • 75
  • 115
  • Hi Erik, how can I check this? – Michel Feinstein Feb 20 '15 at 12:20
  • The command "gacutil -l System.Data.SQLite" on the Developer Command Prompt for VS2013 returns only one item, version 1.0.94.0, is this what you meant? – Michel Feinstein Feb 20 '15 at 14:22
  • Yes, or check add/remove programs. Btw, ẃorking on an update to the blogpost based on feedback... – ErikEJ Feb 20 '15 at 16:17
  • It has been so painful to make it work I am considering switching to sql server compac edition 4, even though it's been deprecated, what's your opinion on this? – Michel Feinstein Feb 20 '15 at 16:34
  • I will try to switch, but still...I feel like this should work, if you want me to give you further details and feedback so this can be mitigated, please let me know – Michel Feinstein Feb 21 '15 at 22:10
  • Check all instructions in the blog post carefully, and also read the comments – ErikEJ Feb 22 '15 at 07:01
  • I have done it all...I wanted SQLite just because SQL Server CE 4 has a 4Gb limit size, but I can't make SQLite work...for such an universal DB, this should be smother for beginners... – Michel Feinstein Feb 22 '15 at 07:08
  • Erik, did you tested this with EF 6.1.2? With SQL Server CE I get another error, please see the post update – Michel Feinstein Feb 22 '15 at 14:41
  • Yes, I did. Did you add the EntityFramework.SqlServerCompact package to your project and build it – ErikEJ Feb 22 '15 at 15:43
  • Yes I did...I just added it and rebuilt (I am even using a x86 project)....I am really lost on this one – Michel Feinstein Feb 22 '15 at 15:52
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/71426/discussion-between-erikej-and-mfeinstein). – ErikEJ Feb 22 '15 at 15:54
0

I got my project to work with SQL Server CE 4.0, but not with SQLite.

I had two projects under the same solution (one for the program itself and another as a test project), and apparently they were conflicting with each other some how. I removed all EF and SQLCE4 references from nuget and etc. from both projects and ONLY added them back to my program project, when it was running as it should, I added it to the test project. I was able to get the Entity Data Model Wizard working, and apparently all is good, but I didn't have done any EF operations so far.

I am really busy with another project so I don't have much time to completely test this, make some CRUD operations and even try it on SQLite. I did a quick test using a new fresh solution and apparently SQLite and SQLSeverCE4 are working, when added to a console app, I added them and generated a Entity Data Model Wizard as the tutorial points out. BUT in my project currently I can't test SQLite for time limitations. I want to give you guys a more complete answer when I have more time but for now, that's all I can test.

Michel Feinstein
  • 13,416
  • 16
  • 91
  • 173
0

I followed the tutorial as well, check everything also in the comments. What was missing on my system (Visual Studio 2015, Entitiy Framework 6.1.3 and sqlite 1.0.103 as nuget packages was to add the following lines in App.config in the section "entityFramework / Providers" (I added it after the standard: provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer")

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

After that, the already included connection to sqlite in the Server Explorer (this worked already) was the standard one for Entity Framework.

pisker
  • 716
  • 6
  • 8