entitiy framework: Multiple Database Providers in single application on single model - entity-framework

I am currently working on an application which was build around EF4 connecting to MSSQL.
Now it was decided, that we should also be able to connect to SQLite.
I've upgraded the application to EF6, made sure everything works as intended with MSSQL and am now trying to get the application to connect to an SQLite DB (which is a converted version of our mssql db).
Sadly I've kinda hit a wall here.
If I try to create the SQLite connection the same way we do for MSSQL
EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder();
entityBuilder.Provider = "System.Data.SQLite.EF6";
entityBuilder.ProviderConnectionString = "data source=sqlite_master.db";
entityBuilder.Metadata = #"res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl";
connection = new EntityConnection(entityBuilder.ToString());
connection.Open();
theEntities = new masterEntities(connection); // masterEntities extends System.Data.Entity.DbContext
getDataBaseVersion();
I get an Exception stating that "System.Data.SQLite.SQLiteConnection" cannot be converted to "System.Data.SqlClient.SqlConnection" in the getDataBaseVersion Method (which is the first one to run a query on the entities).
I've already tried out a few things, but always got either this or an "unintended code first exception".
Btw: I don't really need to create the connection strings for the SQLite version at runtime. If the problem can be fixed by using the config file, I'll gladly do it.
My app.config looks like this:
<entityFramework>
<providers>
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</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" />
</DbProviderFactories>
</system.data>
My guess is that somewhere within the entity data model the data.sqlclient class is set to be used. But I can't create a second Entity Data Model, as then all classes and properties would be definded twice. (I also can't because the sqlite data source won't show up in the assistent for entity data model, but I hope to be able to fix that by reinstalling everything)
Now I wonder: Is it even possible to use two different providers within the same application for the same model?
If yes, I'd be very happy if someone could point me towards a solution to get it working.
Update
I think I've made some progress last night: after adding .EF6 to every System.Data.SQLite in the app.config I now get a different exception.
the app config now looks like this:
<entityFramework>
<providers>
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</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" />
</DbProviderFactories>
</system.data>
I now get an exception stating that the provider name for providerfactory "System.Data.SQLite.SQLiteFactory" cannot be found.
I haven't looked into it yet, gonna do so over the course of the day.
-edit-
My project currently references (among others)
EntityFramework.dll // from nuget
EntityFramework.BulkInsert // from nuget
EntityFramework.MappingAPI // from nuget
EntityFramework.SqlServer // from nuget
System.Data
System.Data.DataSetExtensions
System.Data.Linq
System.Data.SQLite // from the sqlite-netFx451-setup-bundle-x86
System.Data.SQLite.EF6 // from the sqlite-netFx451-setup-bundle-x86

Ok, I give up now.
I've now created a DB-First SQLite Model and I get the same exception, just reversed, when trying to connect to it with the MSSQL Provider.
Looks like I will have to use plan B and compile two versions of our application. One for sqlite and one for mssql.

Related

Firebird EF6 DDEX VS2013 Community Update 4 Dynamic SQL Error

I am trying to read data from an old (but live) Firebird database for my company's ERP. Unfortunately, I have very little info about the Firebird database. It was made by someone else, and I'm not permitted to change it due to the conditions of our service & maintenance agreement.
I have set up the DDEX provider and EF6 provider for VS2013 as well as my project. I am attempting to create an EDM for the database. I have this error when running the Entity Data Model Wizard in Visual Studio:
An error occurred while connecting to the database. The database might
be unavailable. An exception of type
'System.Data.Entity.Core.EntityCommandExecutionException' occurred.
The error message is: 'An error occurred while executing the command
definition. See the inner exception for details. The inner exception
caught was of type 'FirebirdSql.Data.FirebirdClient.FbException', with
this error message: 'Dynamic SQL Error SQL error code = -104 Token
unknown - line 6, column 8 SELECT'. The inner exception caught was of
type 'FirebirdSql.Data.Common.IscException', with this error message:
'Dynamic SQL Error SQL error code = -104 Token unknown - line 6,
column 8 SELECT'.'.
Here is my app.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" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<entityFramework>
<defaultConnectionFactory type="FirebirdSql.Data.EntityFramework6.FbConnectionFactory, EntityFramework.Firebird" />
<providers>
<provider invariantName="FirebirdSql.Data.FirebirdClient" type="FirebirdSql.Data.EntityFramework6.FbProviderServices, EntityFramework.Firebird" />
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="FirebirdSql.Data.FirebirdClient" />
<add name="FirebirdClient Data Provider" invariant="FirebirdSql.Data.FirebirdClient" description=".NET Framework Data Provider for Firebird" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient" />
</DbProviderFactories>
</system.data>
</configuration>
Here is the relevant section of my machine.comfig:
<system.data>
<DbProviderFactories>
<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"/>
<add name="FirebirdClient Data Provider" invariant="FirebirdSql.Data.FirebirdClient" description=".NET Framework Data Provider for Firebird" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient, Version=4.6.0.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c" />
</DbProviderFactories>
</system.data>
I'm using DDEXProvider-3.0.1.0, and both of its DataTools dll's are loaded into the GAC.
I'm using EntityFramework.Firebird-4.6.0.0-NET45, and the dll, FirebirdSql.Data.FirebirdClient is in the GAC.
I'm using Entity Framework 6.1.2 in my solution from NuGet. (Originally I was using 6.0, but I got the same error.)
I'm using Firebird ADO.NET Data Provider in my solution 4.6.0.0 from NuGet.
I'm using Firebird Entity Framework Provider 4.6.0.0 in my solution from NuGet.
My data connection tests okay, and it is using Dialect 3 to communicate with the database. I have experimented with Dialect 1, but it does not solve the problem. I am currently using "none" for the character set.
In Server Explorer, I can browse all folders: Domains, System Tables, Tables, Views, and Stored Procedures with no error.
In my opinion, the error code suggests the Firebird database doesn't like the "." in column 8 of the command. Does anyone have a solution for this? Has anyone even encountered this problem?
Firebird Version 1.5 is too old to be used with Entity Framework. Use gbak to create a portable backup file (fbk) of your database, update the Firebird server to 2.5.3 and run gbak again to restore the database. Now EF should work for you.

SQlite Entity Framework ADO.net provider error 1.0.92.0

I'm trying to understand how SQlite and entity frameworks interacts.
I create a new fresh console project in my visual studio 2013. I install the nuget packet of SQlite 1.0.92.
I create a new empty model (edmx) and try to populate it from a static example database (such as northwind.db).
After this I get this error: error 0175: the ado.net provider named "System.Data.SQLite.EF6" is not registered on the computer.
Any ideas?
Thank you
Lorenzo
After some tests I found a possible solution. Let's start from the beginning:
Download the SQLite ado.net provider from sqlite server (x86 version).
You have to manually register in the GAC those three libraries: system.data.sqlite, system.data.sqlite.ef6, system.data.sqlite.designer with gacutil
Start visual studio 2013. Add reference to nuget sqlite 1.0.92.0 (This will add reference to entity framework 6.1 too).
Your app.config will look like this:
<?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>
<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.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" />
</DbProviderFactories>
</system.data>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<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" />
</providers>
</entityFramework>
<connectionStrings>
Add a new Sqlite connection to the db in your server explorer and test it.
Now add and create a new empty ado.net entity model to your project.
This should work... but when your run the application and pick up some records in one of the dbset you will get an exception telling you that there's no ado.net provider registered for your connection (system.data.sqlite).
Go to your config file and add this to you provider section (just copy the previous sqlite line and cut the .ef6 postfix in the invariant name):
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
Save all and rebuild the application. Now it works but if you go back to the model detail and try to refresh the model from the db you will get a provider exception again. Comment the last provider added and retry. IT WORKS!!!
I think it's due to a conflict between provider names in the syste.data.sqlite and system.data.sqlite.ef6
Despite this I can't do model first (project a model and then create a new database from it) because I get another ado.net provider exception.
Any ideas about that?
Thank you
Lorenzo
_________________ UPDATE 04-2014 _________________
After some testing and googling...
I read that when you want to use the VS design tools you have to install the right x86 version of the SQLite drivers. These drivers, to work properly with the VS tools, needs to register their version of the System.Data.SQLite in the GAC during the installation process (only after this VS knows where to find the connection provider for the design tools).
When you use the model-first approach and you ask the model to create the db instead of use the correct driver registered in you app.config it tryes to open the entity connection with the one registered in GAC and used by the visualmodel creation tool (and wich is not compatible). I think there's no way at the moment to use the VS's entity modelling tool with the SQLite provider.
Lorenzo
#LoxLox : I don't think you have to register dll with GAC. I have same problem like yours but I just need to edit the .config file as discussed in this post by adding .EF6 suffix to invariant.

No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlServerCe.4.0'

I got the following error when I used sqlce 4.0 with entityframework 6.0
No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlServerCe.4.0'
My app.config looks like this
....
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false" />
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, 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" />
</providers-->
</entityFramework>
<connectionStrings>
<add name="FbMultipleInsOrderContainer" connectionString="metadata=res://*/FbMultipleInsOrder.csdl|res://*/FbMultipleInsOrder.ssdl|res://*/FbMultipleInsOrder.msl;provider=System.Data.SqlServerCe.4.0;provider connection string="data source=|DataDirectory|\FBMultipleOrderSync.sdf"" providerName="System.Data.EntityClient" />
</connectionStrings>
...
I tried re-installing EF 6. But no avail.
Any clue on this would be much appreciable.
After installing the EntityFramework.SqlServerCompact nuget package, check that your app.config contains the following (as per #ErikEJ's comment above):
<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>
(You can leave the line for SqlClient even though you don't really need it.)
ErikEJ has pointed this out, but I'd like to highlight the fact, you MUST remember to install the Nuget package
EntityFramework.SqlServerCompact
I tried following the recommended answer, but didn't realise I didn't have the required NuGet package the App.config was referencing.
I met the issue in my unit tests. The tricky thing was that the error had appeared not constantly.
I managed to solve it by adding the follwing class my my unit tests solution:
public static class Trick
{
public static void FixEfProviderServicesProblem()
{
// this commented line should be used for SQL Server provider
//var instance = System.Data.Entity.SqlServer.SqlProviderServices.Instance;
// this is used for SQL Server CE provider
var instance = System.Data.Entity.SqlServerCompact.SqlCeProviderServices.Instance;
}
}
To achieve this you just need to register the EntityFramework.SqlServerCompact in Package Manager Console,
To do this open power manager console and type below command:
PM> Install-Package EntityFramework.SqlServerCompact
To resolve this problem
Visual Studio Menu -> Tools -> NuGet Package Manager - > Manage NuGet Packages for Solution
Select 'Browse' Tab and search for following 'EntityFramework.SqlServerCompact'
Install it.
It should work.
My issue was the unit tests. You likely only installed the Entity framework for your project, but not your unit tests. To do so:
Right click "Solution" in Solution Explorer (not your project's name)
Click "Manage NuGet Packages"
Search for EntityFramework and press it
You will probably not see a tick next to [Project Name].Tests
This error arose on a User PC. The user ignored a previous error "The ‘DbProviderFactories’ section can only appear once per config file".
Apparently DB2 corrupted the machine config file on her PC, by adding a duplicate (and empty) <DbProviderFactories /> tag.
The solution was to delete the empty duplicate tag. The machine config file is located in [WindowsDir]\Microsoft.Net\Framework[.NET Version]\Config\Machine.config
the solution provided is correct but it does not explain why EF need this assembly. Here is Why...
By default EF's configuration allow you to have a "defaultConnectionFactory" uder entityFramework section. This default factory is configured to "LocalDbConnectionFactory" and its param is "mssqllocaldb".
This factory internally requires "SqlServerCe.4.0" i.e. "SqlServerCompact".
The error happens only if the EF uses its default connection string in DbContext. If EF is provided with some other specified Connection string in your config then this error does not appear. Because EF by default uses the default connection factory.
once you install "SqlServerCe 4.0" the configuration of EF is changed and "LocalDbConnectionFactory" and its param is "mssqllocaldb" are replaced with "SqlServer Ce 4.0". and EF runtime is also able to find the SqlServerCe4.0 Assembly (as it is now part of your references and physically placed in your BIN).
Following is the EF Config before and after installing Sql Server Compact
OLD Config:
<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" />
</providers>
</entityFramework>
The new configuration is as below:
<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>
and also it added the following section to describe new Factory
<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>
Don't forget that Package Manager Console takes app.config/web.config from selected as Startup project!
For me, because the programmer is not only one, some programmer is already install EntityFramework.SqlServerCompact, but when I pull in my PC and RUN shows above error message, then I just Uninstall and install again.
Within Visual Studio, all the .dll files that exist in _bin_deployableAssemblies folder need to be set to Build Action : none
All the .dll's for me were set to content.
This is what I set it to, and it worked straight after:
I add the provider code below to the Web.config,and install the EntityFramework.SqlServerCompact package both, and then solve the problem.
If lacking one, it fails.
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact"/>

Connecting to SQL Server with EF6

Up to EF5, in order to connect to SQL Server 2012, all I needed to to is specify a connection string that looks something like this:
Data Source=.\SqlExpress;Initial Catalog=MyDatabase;Integrated security=True;MultipleActiveResultSets=True
This method is not working with EF6, giving exception
No Entity Framework provider found for 'System.Data.Odbc' ADO.NET provider. Make sure the provider is registered in the 'entityFramework' section of the application config file
I am not using app.config file at all, I am passing above connection string to MyContext constructor. WHy is it trying to use Odbc provider at all, and instead not using System.Data.SqlClient?
What needs to be done to connect to SQL Server with EF6 code-first? I made sure that EntityFramework.dll and EntityFramework.SqlServer.dll are both available in Application folder. I have even added EF6 nuget package v6.0.0.1 in WPF project, although it does not use EF library directly, and making sure that automatically created App.Config file (by nuget) is copied to Application (Debug) folder - still no success.
I have also tried to setprovider manually in code:
public class OeeCoachConfiguration : DbConfiguration
{
public OeeCoachConfiguration()
{
SetProviderServices("System.Data.SqlClient",
System.Data.Entity.SqlServer.SqlProviderServices.Instance);
}
}
Still no success. My Project structure is as follows (simplified):
WPF project - does not have reference to EF (also tried adding EF reference)
ViewModel class library - does not have reference to EF
Model class library - has reference to EF library (both dlls)
Data class library - has reference to UI library (both dlls).
I am using CodeFirst approach, and this setup works without any problem with EF5. Any help is greatly appreciated.
For me this error was resolved by removing the Glimpse.ADO package
Edit December 20, 2013 I believe the Glimpse.ADO package now supports EF6, but I have not tested it.
I had the same problem and I eventually tried the following and it worked (keeping Glimpse EF5 & Glimpse ADO packages)
In the web.config I added a copy of the existing provider line but changed it's invariantName to "System.Data.Odbc".
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.Odbc" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
Hope that this helps.
Jonathan
Yes, for me it was resolved by removing Glimpse.ADO and Glimpse.EF5 nuget packages. Thank you.
Option 1: Try adding following in app.config of the executable project.
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
Option 2: If you want to use code based provider registration, follow guideline on Entity Framework Providers for EF6
Make sure you have the DbConfiguration in the same assembly as the DbContext of your application.

Entity Framework 5 Code Migration doesn't create database

I'm trying to use Entity Framework 5 Code First.
I've created model classes and context.
After that following Microsoft instructions I've enabled code migrations.
Than I skipped running my application (during which DB should be created first time) and use Add-Migration command. Migration was generated successfully.
Update-Database call was also successfull. But I'm not seeing my DB at all. It is absent!
SQL Management Studio and Visual Studio Server Explorer show only 4 default system databases and that's all!
I also tried to launch my application - it doesn't change anything.
I'm using
public MyContext() : base("name=MyContext") { }
such type of constructor (so I need specify connection string with MyContext name.
Here is my app.config example:
<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=5.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>
</entityFramework>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<connectionStrings>
<add name="BettyContext" providerName="System.Data.SqlServerCe.4.0" connectionString="Data Source=MyDB.sdf"/>
</connectionStrings>
</configuration>
I have no idea what's going on. Seems that no one has such problem. May be I've missed some evident thing, but howbeit I'm waiting for some help.
Do you see an exception? If you don't see an exception you probably are not looking at the right database. You can try adding some data to the database with your app and then read it. If the data can be successfully added and read and you still don't see the database it would confirm that you are looking at wrong database.