views:

81

answers:

2

How do I deploy SQL CE 4.0 with EF4 to a shared hosting provider for ASP.NET MVC 2.0?

I've included System.Data.SqlServerCe.dll, and the amd64 + x86 directories in my bin folder, but keep getting a ".net provider not found". I realize it's currently in CTP, but this is just for testing purposes. My project + host is configured for .net 4.0

A: 

I have same issue. I tried this http://erikej.blogspot.com/2010/07/getting-started-with-sql-server-compact.html but no success :(

Daniel Steigerwald
+1  A: 

There are two possibilities which may cause this problem:

  1. When you install SQL CE on the development machine with the Windows Installer, an entry to machine.config is added for the provider. However when you deploy to the hosting, the provider entry will not possibly exist so you should add this entry to your web.config (especially for EF to work I guess):

    <system.data>
      <DbProviderFactories>
       <add 
        name="SQL Server Compact Edition 4.0" 
        invariant="System.Data.SqlServerCe.4.0"
        description=".NET Framework Data Provider for Microsoft SQL Server Compact Edition 4.0" 
        type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
      </DbProviderFactories>
    </system.data>
    
  2. SQL CE 4.0 looks promising but deployment still sucks, we still need to include several native DLLs (amd64 and x86 directories, this is ugly) and in addition there is a dependancy on Visual C++ 2008 Runtime Libraries SP1 which no one seems to be aware of. How are we supposed to be sure a shared hosting has this fix? I wish we were able to deploy simply by including System.Data.SqlServerCe.dll (and System.Data.SqlServerCe.Entity.dll for EF support). I hope they release a fully managed version (like VistaDB) in the future. At least MS should have forced this runtime along with .Net Framework 4.0 installation, see below for more information:

    Installing the SQL Server Compact 4.0 CTP1 using the Windows Installer (.exe) file, also installs the Visual C++ 2008 Runtime Libraries SP1. If SQL Server Compact 4.0 CTP1 is deployed privately in the application’s folder the following have to be present on the machine for SQL Server Compact to function properly:

    1.Installing the .NET Framework 3.5 SP1 also installs the Visual C++ 2008 Runtime Libraries SP1.

    2.Visual C++ 2008 Runtime Libraries SP1 can be downloaded and installed from the location given below: http://go.microsoft.com/fwlink/?LinkId=194827

    Note that installing .NET Framework 2.0 or 3.0 or 4 does not install the Visual C++ 2008 Runtime Libraries SP1.

tester
Any idea how to deploy the Visual C++ 2008 Runtime to shared hosting if it's not already deployed?
Andrew Lewis
I am not sure if you can deploy the runtime. Maybe determining the required runtime DLLs and deploying to the bin\x86 and bin\amd64 folders may work. By the way I added another possibility (a web.config setting) in my reply which may solve your problem.
tester