Unable to find the requested .Net Framework Data Provider. It may not be installed.

2011-09-09


We have a small MVC project, once a time we got the following error message in a popup window:

…. Unable to find the requested .Net Framework Data Provider. It may not be installed.

The reasons are very depends, there are lots of different reasons on the internet. Our case looks some special: The reason we finally found was about Microsoft SQL Server CE database.

We wrote the code in Visual Studio 2010, we added a database connection string in web.config:

<connectionStrings>

  <add name="TestDBContext" 
    connectionString="Data Source=|DataDirectory|TestDatas.sdf" 
    providerName="System.Data.SqlServerCe.4.0"/>    
  
  <add name="ApplicationServices" 
       connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" 
       providerName="System.Data.SqlClient" /> 
</connectionStrings>

You can see here we used SQL Server CE database;

Also, In our MVC Models folder, we have already a TestData class:

using System.Data.Entity;

public class TestData 
{ 
    public int ID { get; set; } 
    public string Name { get; set; } 
    public decimal Length { get; set; } 
}

public class TestDBContext : DbContext 
{ 
    public DbSet<TestData> TestDatas { get; set; } 
} 

Now we wanted to add a Controller, we set the controller adding window like following:

sqlCEError0

Then we got the error message which we mentioned at the beginning of this article.

…. Unable to find the requested .Net Framework Data Provider. It may not be installed.

The reason is that we had not installed SQL Server CE 4.0 engine yet.

Go to Microsoft official site to find how to install SQL Server Compact 4.0, We had already posted an article about how to install SQL Server CE 4.0. However, we should NOT ONLY install SQL Server Compact 4.0, but also the tools for Visual Studio 2010, and some objects for related management tools such as Visual Studio Management. So the complete install package should get from here (You should allow Microsoft Web Installer run if your web browser give you a warning message).

sqlCEError1

After the engine installed, when we did adding the controller above, the error message not shown any more.