-2

Our application currently running on X86 mode with SQL Server CE 3.5. I need to move to ANYCPU mode. I tried to upgrade SQL Server CE 4.0 since I heard that SQL Server CE 3.5 doesn't support for ANYCPU. Change my project to ANYCPU already but gave me following errors when try to open SQL Server Compact file. Please help.

Unable to load the native components of SQL Server Compact corresponding to the ADO.NET provider of version 8080. Install the correct version of SQL Server Compact. Refer to KB article 974247 for more details.

Unable to load DLL 'sqlceme35.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Dilhan RK
  • 114
  • 1
  • 7
  • Did you actually read the KB article that the error message points to? It provides the steps to take the resolve this. – Brendan Green Mar 21 '17 at 00:54
  • Yes. I went through [this](https://support.microsoft.com/en-au/help/974247/fix-you-receive-an-error-message-when-you-run-a-sql-server-compact-3.5-based-application-after-you-install-the-32-bit-version-of-sql-server-compact-edition-3.5-service-pack-2-on-an-x64-computer) article. Doesn't help. – Dilhan RK Mar 21 '17 at 01:30
  • I created small console application to check the issue. Console application does work with SQL Server CE 3.5. But it never works with SQL Server CE 4.0. No matter I am using X86 or ANYCPU. So I think is something related to SQL Server CE 4.0. Need to find out that first. – Dilhan RK Mar 21 '17 at 01:35
  • I manage to fixed the above issue by using C:\Program Files\Microsoft SQL Server Compact Edition\v4.0\Desktop\System.Data.SqlServerCe.dll. So the System.Data.SqlServerCe.dll in path C:\Program Files\Microsoft SQL Server Compact Edition\v4.0\Private doesn't work. – Dilhan RK Mar 21 '17 at 01:53

1 Answers1

0

I have to upgrade my current SQL Server Compact files to used in SQL Server Compact version 4.0. So I used following code to upgrade SQL Server Compact version 3.5 files to 4.0.

public static void Upgrade(string fileName, string password)
    {
        if (String.IsNullOrEmpty(fileName) || password == null)
            throw new Exception("Unable to create connection string because filename or password was not defined");

        try
        {
            var connectionString = string.Format(@"Data source={0};Password={1}", fileName, password);
            var engine = new SqlCeEngine(connectionString);
            engine.Upgrade();
        }
        catch (Exception ex)
        {
            throw (ex);
        }
    }

Need to Allows SQL Server Compact 4.0 to be used with Entity Framework. To install EntityFramework.SqlServerCompact, run the following command in the Package Manager Console

Install-Package EntityFramework.SqlServerCompact -Version 4.1.8482.2

Dilhan RK
  • 114
  • 1
  • 7