locked
System.Data.SqlServerCe.SqlCeInvalidDatabaseFormatException occurred in 4.0 entity framework projects RRS feed

  • Question

  • Hi All,

    I am facing an exception System.Data.SqlServerCe.SqlCeInvalidDatabaseFormatException with entity framework project in 4.0 framework version only. This issue occurs only in 4.0 framework projects and the same project with other frameworks are working fine. I have just installed VS2017 RC in the machine. and this issue occurs in this machine only.

    Exception occurs in the below code,

    //Create a connection object for entity connection.
    EntityConnection con = new EntityConnection("name=NorthwindGridEntities");

    I have noticed, this exception didn't occur in a machine installed with VS2010, VS2012, VS2013 and VS2015.

    Here is the code block in App.Config file,

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>  
    <connectionStrings><add name="NorthwindGridEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlServerCe.3.5;provider connection string=&quot;Data Source=D:\ImportantSampels\NorthwindGrid.sdf&quot;" providerName="System.Data.EntityClient" /></connectionStrings></configuration>


    Please anyone let me know, why this exception occurs in 4.0 framework projects only with VS2017 RC build.

    Regards,


    Amal Raj U


    • Edited by Amal Raj U Tuesday, January 24, 2017 7:37 AM
    • Moved by CoolDadTx Tuesday, January 24, 2017 2:50 PM EF related
    Tuesday, January 24, 2017 7:28 AM

All replies

  • This error occurs because you are using the SQL Compact 4.0 provider against an (older) format database file. Please check the file (you can use my SQL Compact Toolbox for that), and also check that the correct version is in your app.config file.


    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com

    Tuesday, January 24, 2017 5:08 PM
  • Hi Amal Raj U,

    Agree with ErikEJ, A System.Data.SqlServerCe.SqlCeInvalidDatabaseFormatException exception occurs when SQL Server Compact opens a database file that was created in an earlier version of the product.

    You can update the database file by using Visual Studio 2017 or by using the API System.Data.SqlServerCe.SqlCeEngine.Upgrade.

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 25, 2017 3:24 AM