ASP.NET MVC 4 + Entity Framework 6 + SQL Compact Edition 4.0 deployment no install - deployment

Im trying to deploy a basic MVC 4 app that uses Entity Framework 6 (Code First) and SQL Compact 4.0
on a clean install of windows 7 with iis installed (mvc 4 and sql compact 4.0 is not installed).
I got the following nuget packages installed on the db project:
EntityFramework (Version 6.0.0-alpha2)
EntityFramework.SqlServerCompact (Version 6.0.0-alpha2)
Microsoft.AspNet.Providers (Version 1.2)
Microsoft.AspNet.Providers.Core (Version 1.2)
Microsoft.SqlServer.Compact (Version 4.0.8876.1)
In web.config i got the following config:
<connectionStrings>
<add name="[Name]" connectionString="Data Source=|DataDirectory|[FileName].sdf" providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
......................
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</providers>
</entityFramework>
Bin folder (sql ce files are in amd64 and x86 folder:
[amd64]
[x86]
Antlr3.Runtime.dll
DotNetOpenAuth.AspNet.dll
DotNetOpenAuth.Core.dll
DotNetOpenAuth.OAuth.Consumer.dll
DotNetOpenAuth.OAuth.dll
DotNetOpenAuth.OpenId.dll
DotNetOpenAuth.OpenId.RelyingParty.dll
EntityFramework.dll
EntityFramework.SqlServer.dll
EntityFramework.SqlServer.xml
EntityFramework.SqlServerCompact.dll
EntityFramework.SqlServerCompact.xml
EntityFramework.xml
Microsoft.Web.Infrastructure.dll
Microsoft.Web.WebPages.OAuth.dll
Newtonsoft.Json.dll
ShipMedProto.DB.dll
ShipMedProto.DB.pdb
ShipMedProto.Web.dll
ShipMedProto.Web.pdb
System.ComponentModel.DataAnnotations.dll
System.Data.DataSetExtensions.dll
System.Data.SqlServerCe.dll
System.Data.SqlServerCe.Entity.dll
System.Net.Http.Formatting.dll
System.Web.Helpers.dll
System.Web.Http.dll
System.Web.Http.WebHost.dll
System.Web.Mvc.dll
System.Web.Optimization.dll
System.Web.Providers.dll
System.Web.Razor.dll
System.Web.WebPages.Deployment.dll
System.Web.WebPages.dll
System.Web.WebPages.Razor.dll
WebActivatorEx.dll
WebGrease.dll
WebMatrix.Data.dll
WebMatrix.WebData.dll
When I deploy to the clean machine I get the following error message:
Unable to find the requested .Net Framework Data Provider. It may not be installed.
On my dev machine it is working fine. (I got sql ce installed)
Any clue what Im doing wrong?

I think what you really want to do is manage the NuGet packages such that you add SqlServerCompact support for EntityFramework. Just right click your references and Manager NuGet packages. Then in the dialog do a search for SqlServerCompact. You SHOULD see this:
Adding this should add the equivalent strings that were in the answer above. I ended up with this in the web.config (or app.config if you're doing an app)
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0" />
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
</system.data>
Sorry, I'm about a year late but hopefully this helps someone else.

This is a configuration I am using that works.
I've added the projects from NuGet:
EntityFramework (6.0.1)
EntityFramework.SqlServerCompact (6.0.1)
Microsoft Sql Server Compact Edition (4.0.8876.1). Note, I do not have this assembly flagged to copy local.
I've added the files from the SQLCE 4 private install folders
And then I set my config as follows:
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="SecureSend.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<loadFromRemoteSources enabled="true" />
<ThrowUnobservedTaskExceptions enabled="true" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin"/>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Data.SqlServerCe" publicKeyToken="89845dcd8080cc91" />
<bindingRedirect oldVersion="0.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
</providers>
</entityFramework>
<connectionStrings>
<add name="LocalUserContext" connectionString="Data Source=c:\temp\LocalUserDataStore.sdf" providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0" />
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
</system.data>
</configuration>

Related

devexpress xaf database from SQL SERVER to POSTGRESQL

I'm trying to execute the most basic XAF example from devexpress website with PostgreSQL. How can I do it? I've added Entityframework6.Npgsql (from https://www.nuget.org/packages/EntityFramework6.Npgsql/) to sampleErp.Module project and changed the file app.config in project sampleErp.Win. I've also added EntityFramework6.Npgsql to the GAC.
Here is my app.config file:
<?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" />
</configSections>
<appSettings>
<add key="Modules" value="" />
<add key="NewVersionServer" value="" />
<add key="EnableDiagnosticActions" value="False" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<connectionStrings>
<add name="EasyTestConnectionString" connectionString="Server=127.0.0.1;User Id=postgres;Password=postgres;Database=mobi03xaf;" providerName="System.Data.EntityClient" />
<add name="ConnectionStringEF" connectionString="Server=127.0.0.1;User Id=postgres;Password=postgres;Database=mobi03xaf;" providerName="System.Data.EntityClient" />
<add name="ConnectionString" connectionString="Server=127.0.0.1;User Id=postgres;Password=postgres;Database=mobi03xaf;" providerName="System.Data.EntityClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="Npgsql.NpgsqlConnectionFactory, Npgsql" />
<providers>
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, EntityFramework6.Npgsql" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="Npgsql" />
<add name="Npgsql Data Provider"
invariant="Npgsql"
support="FF"
description=".Net Framework Data Provider for Postgresql"
type="Npgsql.NpgsqlFactory, Npgsql" />
</DbProviderFactories>
</system.data>
<system.diagnostics>
<switches>
<add name="eXpressAppFramework" value="3" />
</switches>
</system.diagnostics>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
I've also installed Npgsql.dll to the GAC by command gacutil /i path\npgsql.dll.
Here is log of the command:
gacutil /l
Npgsql, Version=3.0.7.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL.
But when I try execute project, I'm getting the following error:
InnerException:
Type: InvalidOperationException
Message: The Entity Framework provider type 'Npgsql.NpgsqlServices, EntityFramework6.Npgsql' registered in the application config file for the ADO.NET provider with invariant name 'Npgsql' 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.
Data: 0 entries
Stack trace:
How can I solve this problem?

Entity Framework looks for ADO.NET provider SqlServerCe.3.5 instead of 4.0

I am using SQL Server CE 4.0 along with entity framework 6.0. Everythings work fine until I wanted to enable a N-Tier syncing mechanism with a remote database using a WCF service and the Sync Framework 2.1.
I followed this tutorial and use the JTune's workaround to overcome the issue that the SyncFramework 2.1 and SQLSErverCompactCE 4.0 compatibility is not supported. Which is simply a runtime binding redirect in app.config for System.Data.SqlServerCE.dll 4.0.0
Then I get the following App.config file
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
</providers>
</entityFramework>
<connectionStrings>
<add name="Entities" connectionString="metadata=res://*/Persistence.Model1.csdl|res://*/Persistence.Model1.ssdl|res://*/Persistence.Model1.msl;provider=System.Data.SqlServerCe.4.0;provider connection string="data source=|DataDirectory|\XXXX.sdf"" providerName="System.Data.EntityClient" />
</connectionStrings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Data.SqlServerCe" publicKeyToken="89845DCD8080CC91" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0" />
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
</system.data>
</configuration>
It works fine on some configuration but may fail with the following error.
No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlServerCe.3.5'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
Remark that the solution provided in this question is not viable, because in my situation, I really need the binding redirect to use SyncFramework.
Is there a way to tell entity framework not to look for a SQL Server CE 3.5 provider and only for the 4.0?
I think I got this. When SQL Server CE 3.5 is installed on the machine then its added to the DbProviders in the machine.config and depending on its position regarding the 4.0 version you may have the failure (see my comment above). It looks like the app.config lets you the possibility to remove a DbProviderFactory. I added the following line in my app.config and the problem seems to be resolved
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.3.5" />
</DbProviderFactories>
</system.data>

Why is Migrations looking for Sql Server Provider?

Here is my config...
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DataContext" connectionString="Server=localhost;Port=5432;Database=myDatabase;User Id=postgres;Password=password;Preload Reader = true;" providerName="Npgsql" />
</connectionStrings>
<entityFramework>
<providers>
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />
</providers>
</entityFramework>
</configuration>
When I run update-database it gives at the end of the stack trace...
No Entity Framework provider found for the ADO.NET provider with
invariant name 'System.Data.SqlClient'. Make sure the provider is
registered in the 'entityFramework' section of the application config
file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more
information.
Another error I'm running into when I add to the entityFramework section..
<defaultConnectionFactory type="Npgsql.NpgsqlFactory, Npgsql" />
Failed to set Database.DefaultConnectionFactory to an instance of the
'Npgsql.NpgsqlFactory, Npgsql' type as specified in the application
configuration.
What am I missing?
You could try using a DbProvidersFactories instead of the connection string:
<system.data>
<DbProviderFactories>
<remove invariant="Npgsql" />
<add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql" type="Npgsql.NpgsqlFactory, Npgsql" />
</DbProviderFactories>
</system.data>
I got this working by adding Entityframework, Npgsql and Npgsql.Entityframework as three individual installs using Nuget. Then the following config...
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<connectionStrings>
<add name="[Name of EF Context class]" connectionString="Server=localhost;Port=5432;Database=[Name of existing database];User Id=[username];Password=[password];" providerName="Npgsql" />
</connectionStrings>
<entityFramework>
<providers>
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework"></provider>
</providers>
<defaultConnectionFactory type="Npgsql.NpgsqlConnectionFactory, Npgsql.EntityFramework" />
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="Npgsql" />
<add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql" type="Npgsql.NpgsqlFactory, Npgsql" />
</DbProviderFactories>
</system.data>
</configuration>

Unable to find the requested .Net Framework Data Provider. It may not be installed

This morning I suddenly got this exception when trying to add a custom migration step to our EF Code-first migrations:
The ADO.NET provider with invariant name '.NET Framework Data Provider for SQL Server' is either not registered in the machine or application config file, or could not be loaded.
I have no problem executing a update-database against our SQL Server but the add-migration command fails.
We are using.Net 4.5.1 with EF Code First 6.0.1 against SQL Server 2012.
Our configuration file for our data project is this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlClient" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="Data.StorageContext" connectionString="server=.\MSSQL01;Database=OutageTracking; Integrated Security=True; MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
</configuration>
Note that Visual Studio 2012 complains about the -element in the -section.
Any thoughts?
Thanks,
/Jesper
".NET Framework Data Provider for SQL Server" is not an invariant name, so some .config file somewhere must be in a bad state

Entity Framework 6 + SQLite

I'm trying to use EF6 alpha and SQLite 1.0.66.0
My .config file:
<connectionStrings>
<add connectionString="data source=:memory:;" name="TestDbContext" providerName="System.Data.SQLite" />
</connectionStrings>
<entityFramework>
<providers>
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
</providers>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<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, Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
</DbProviderFactories>
</system.data>
When I run
using (var dbContext = new TestDbContext())
{
if (dbContext.Database.Exists())
{
dbContext.Database.Delete();
}
dbContext.Database.Create();
}
I get an error:
System.InvalidOperationException: System.InvalidOperationException:
The 'Instance' member of the Entity Framework provider type
'System.Data.SQLite.SQLiteFactory, System.Data.SQLite,
Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139'
did not return an object that inherits from
'System.Data.Entity.Core.Common.DbProviderServices'. Entity Framework
providers must extend from this class and the 'Instance' member must
return the Singleton instance of the provider..
What am I doing wrong?
if you used EF 6.1.3 + System.Data.SQLite v1.0.96.0, just adjust(add) the following declarations in the web.config. (you can find the difference with some text-compare tool, i have numbered them).
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<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" />
<!-- 1. Solves SQLite error of "Unable to find the requested .Net Framework Data Provider."-->
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<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" />
<!-- 2. Solves SQLite error of "Unable to find the requested .Net Framework Data Provider."-->
<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>
It works for me.
The System.Data.SQLite Entity Framework provider will need to be updated to work with version 6 of the Entity Framework. (See Rebuilding EF providers for EF6)
For SQLite, this is a fairly trivial task:
Download and open the System.Data.SQLite.Linq project
Remove the reference to System.Data.Entity.dll
Add a reference to EntityFramework.dll version 6
Update the broken namespace references
Rebuild the provider
Jun 21, 2013 Update:
I've shared an updated version of the provider on my blog. See System.Data.SQLite on Entity Framework 6 for more information.
I put working solution of EF 6.0 with Sqlite on my Bitbucket account: https://zchpit#bitbucket.org/zchpit/sqlitesamples.git
or git
https://github.com/zchpit/SQLiteSamples
You can download working solution from that git repository. In my solution, I connect to Sqlite by:
Data Reader
Simple.Data
EF 6.0
p.s. my App.config
<?xml version="1.0"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="true" />
</configSections>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.96.0" newVersion="1.0.96.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite.EF6" />
<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>
<connectionStrings>
<add name="SqlLiteContext" connectionString="Data Source=|DataDirectory|MyDatabase.sqlite" providerName="System.Data.SQLite" />
</connectionStrings>
<entityFramework>
<providers>
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/>
</providers>
<defaultConnectionFactory type="System.Data.SQLite.SQLiteFactory, EntityFramework">
<parameters>
<!---parameter value="v11.0" />-->
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>
System.Data.SQLite 1.0.91.0 has been updated to support EF6. Many thanks for Brice's EF SQLite excellent tutorial and update. You need to update your app.config for the new changes if you want it to work with the tutorial. I can confirm that this has worked for me on VS 2010:
<?xml version="1.0"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0"/>
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6, Version=1.0.91.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
</providers>
</entityFramework>
<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, Version=1.0.91.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
</DbProviderFactories>
</system.data>
<connectionStrings>
<add name="ChinookContext" connectionString="Data Source=|DataDirectory|Chinook_Sqlite_AutoIncrementPKs.sqlite" providerName="System.Data.SQLite"/>
</connectionStrings>
</configuration>
The exception disappeared when reinstalled the NuGet package (System.Data.SQLite version 1.0.94.1) with
Update-Package –reinstall System.Data.SQLite