I have a SQL Server CE 4.0 database (.sdf
file) and when I trying doing a query on the database from my application (WPF) I get the following error.
Incompatible Database Version. If this was a compatible file, run repair. For other cases refer to documentation. [ Db version = 4000000,Requested version = 3505053,File name = \?\C:\Database\ShortageReport\MRPDatabase.sdf]
app.config
.I am using SQL Server Compact Toolbox to generate the context and the mappings.
My app.config
:
<connectionStrings>
<add name="DatabaseContext"
providerName="System.Data.SqlServerCe.4.0"
connectionString="Data Source=C:\Database\ShortageReport\MRPDatabase.sdf"/>
</connectionStrings>
Any ideas?
Add a reference to the version 4.0 System.Data.SqlServerCe.dll ADO.NET provider
Then initialize the DataContext
class with a SqlCeConnection
(4.0) object.
using (SqlCeConnection conn = new SqlCeConnection(@"Data Source=C:\projects\Chinook\Chinook40.sdf"))
{
using (Chinook db = new Chinook(conn))
{
var list = db.Album.ToList();
if (list.Count > 0)
System.Diagnostics.Debug.Print("It works!");
}
}