System.Data.SQLite

Login
This project makes use of Eagle, provided by Mistachkin Systems.
Eagle: Secure Software Automation
Ticket Hash: d6e1fdba1e2b1f5ce470aa7386f129fa6df442e6
Title: EdmGen.exe won't work with a System.Data.SQLite version greater than 1.0.94.0
Status: Closed Type: Incident
Severity: Important Priority: Medium
Subsystem: LINQ Resolution: Works_As_Designed
Last Modified: 2017-11-11 17:23:20
Version Found In: 1.0.95.0+
User Comments:
anonymous added on 2017-10-31 08:24:17: (text/html)
<p>I've been trying to set up entity framework with System.Data.SQLite (targeting .NET 4.0). I'm using Visual Studio 2017, so I know there are no design time components available.</p>

<p>I happened upon this guide for manually setting everything up: <a href="https://liiw.blogspot.co.uk/2014/12/sqlite-entity-framework-database-first.html">https://liiw.blogspot.co.uk/2014/12/sqlite-entity-framework-database-first.html</a></p>

<p>I will however summarise what I've got from following the instructions in the link above:</p>

<p>A single folder, containing the following items:</p>

<ul>
<li><code>EdmGen.exe</code> (copied from C:\Windows\Microsoft.NET\Framework\v4.0.30319)</li>
<li><code>EdmGen.exe.config</code></li>
<li><code>x86</code> and <code>x64</code> folders, each containing their own respective SQLite.Interop.dll</li>
<li><code>System.Data.SQLite.dll</code></li>
<li><code>System.Data.SQLite.EF6.dll</code></li>
<li><code>System.Data.SQLite.Linq.dll</code></li>
<li><code>TestDatabase.sqlite</code>, which contains some test tables.</li>
<li><code>gen.bat</code></li>
</ul>
The content of EdmGen.exe.config is as follows:

<code><pre><configuration>
    <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>
</configuration></pre></code>

<p>The content of gen.bat is as follows:</p>
<code>EdmGen.exe /mode:fullgeneration /c:"Data Source=TestDatabase.sqlite" /provider:System.Data.SQLite /entitycontainer:TestDatabase /project:TestDatabase /language:CSharp
</code>

<p>Running gen.bat (or the command above) with the System.Data.SQLite binaries being the latest version of System.Data.SQLite (or any version greater than 1.0.94.0) produces the following error:</p>

<code><pre>error 7001: The provider returned schema mapping information that is not valid.
        Schema specified is not valid. Errors:
StoreSchemaDefinition(2,65) : error 0175: The specified store provider cannot be found in the configuration, or is not valid.</pre></code>

<p>It works with version 1.0.94.0 of the System.Data.SQLite assemblies.

Googling the errors has not turned up any answers as to the problem I am experiencing. What is it that I am doing wrong here?</p>

I also posted this as a Question on Stackoverflow yesterday: <a href="https://stackoverflow.com/questions/47025852/edmgen-exe-wont-work-with-a-system-data-sqlite-version-greater-than-1-0-94-0">https://stackoverflow.com/questions/47025852/edmgen-exe-wont-work-with-a-system-data-sqlite-version-greater-than-1-0-94-0</a>

<p>I am hoping that I have supplied all the necessary information here, but if any more is required then I shall endeavour to provide it.  I've also done my best to try and ensure the text of this post is formatted correctly.</p>

mistachkin added on 2017-11-01 00:24:47: (text/x-fossil-plain)
Ok.  I've managed to figure out why you are hitting this error.

The EdmGen tool is apparently not compatible with EF6.  Instead, you will want
to use the legacy provider, which is System.Data.SQLite.Linq.

In the "EdmGen.exe.config" file, use:

<configuration>
    <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" />
            <remove invariant="System.Data.SQLite.Linq" />
            <add name="SQLite Data Provider (LINQ)" invariant="System.Data.SQLite.Linq" description=".NET Framework Data Provider for SQLite (LINQ)" type="System.Data.SQLite.Linq.SQLiteProviderFactory, System.Data.SQLite.Linq" />
        </DbProviderFactories>
    </system.data>
    <system.diagnostics>
      <trace autoflush="true" indentsize="4">
        <listeners>
          <add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="TextWriterOutput.log" />
          <remove name="Default" />
        </listeners>
      </trace>
    </system.diagnostics>
</configuration>

And then in the "gen.bat" file:

EdmGen.exe /mode:fullgeneration /c:"Data Source=TestDatabase.sqlite" /provider:System.Data.SQLite.Linq /entitycontainer:TestDatabase /project:TestDatabase /language:CSharp

The "EdmGen.exe.config" file above will also generate a trace log file in the
current directory, which may be useful in debugging.  You can remove that
section if you like.

anonymous added on 2017-11-11 13:15:07: (text/x-fossil-plain)
Sorry for taking a long time to get back to you.  What you suggest does work for generating the entity framework objects, however based on what you're saying, it sounds like the generated objects are not the EF6 ones (unless I've misinterpreted you)?

Do you know of any way to generate the EF6 objects for System.Data.SQLite outside of Visual Studio?

I apologise if my questions are dumb here, as I'm afraid I'm fairly new to entity framework.

mistachkin added on 2017-11-11 17:23:20: (text/x-fossil-plain)
I don't really use EF6 myself and I'm not sure how to generate the objects outside
of Visual Studio.