Incompatible Database Version. If this was a compatible file, run repair

Problem

You get this error when running your application:

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:\Testing Code\bakery.sdf ]

In your application, you are allowed to use either Microsoft SQL CE 3.5 or 4.0 but not both.  If your application is set to used Microsoft SQL CE 4.0, the following will be present in the web.config file:

<dependentAssembly>

            <assemblyIdentity name="System.Data.SqlserverCe" publicKeyToken="89845dcd8080cc91"/>

            <bindingRedirect oldVersion="3.5.1.0" newVersion="4.0.0.0"/>

</dependentAssembly>

…in this section:

<runtime>

            <assemblyBinding …>

In the case that this is not present, if your application attempts to connect a 4.0 CE database, you will get this error.

Solution

Convert your databases to be either Microsoft SQL CE 3.5 or 4.0 so that they all have the same version.   Then, select “Databases->Synchronization Database Schema”   If your application uses Microsoft SQL CE 3.5 database files, make sure Microsoft SQL CE 3.5 is installed in your system.  If your application uses Microsoft SQL CE 4.0 database files, make sure Microsoft SQL CE 4.0 is installed in your system that can be downloaded from http://www.microsoft.com/download/en/details.aspx?id=17876

See Also

Part VII:  Troubleshooting Applications

Application Will Not Run

Application Runs But No Data is Displayed

Application Error Messages