Work on SQL Compact Edition 4.0

All of us we have installed at least SQL express and when we work with SQL CE nothing else is necessary to be installaed.
But when the project will be published in a computer without SQL installed we will get many errors.

Usally the errors are:
Unable to find the requested .Net Framework Data Provider. It may not be installed.

Stack Trace: [ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.]

You can solve this adding System.Data.SqlServerCe and modifying the web.config adding these lines:

    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
        <parameter value="System.Data.SqlServerCe.4.0" />
      <remove invariant="System.Data.SqlServerCe.4.0" />
      <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />

This fix that error but generate this one:
Could not load file or assembly ‘System.Data.SqlServerCe.Entity, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91’ or one of its dependencies. The system cannot find the file specified.

You can fix it also by yourself by adding System.Data.SqlServerCe.Entity


Solve all errors by your hand is very annoying and required many time, the quick solution is achieved by using NuGet.
Open NuGet and add to the project these packages:

All development error will be solved 🙂

The last error you can receive is:
Access to the database file is not allowed

This one is not a code error but a file permission problem.
Go to the database file and add the read/write access to the application pool user.


Informazioni su Andrea Regoli

Project Manager .Net Developer WPF WP7 Asp.Net c# javascript ajax SQL sharepoint
Questa voce è stata pubblicata in .Net, Asp.Net, SQL e contrassegnata con , , , , , . Contrassegna il permalink.


Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:


Stai commentando usando il tuo account Chiudi sessione /  Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )


Connessione a %s...

This site uses Akismet to reduce spam. Learn how your comment data is processed.