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!");
}
}
I updated SqlServerCe.dll reference from following path, and it fixed
Reference Path:
C:\Program Files\Microsoft SQL Server Compact Edition\v4.0\Desktop\System.Data.SqlServerCe.dll
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With