"Cannot find the requested .Net Framework data provider. It may not be installed."

I know that there were many other reports of this error, but no one was able to shed light or help on my problem. I use a direct connection to SqlExpress, so there are no special Oracle or MySQL databases or anything else. Looks like it should just fit like a glove.

So the scenario is this: I created a solution consisting of several projects; Repositories, data (EF5.0), utilities, test project, and MVC web application. The goal is simply to access the underlying SQL Express database through the data classes through the repositories in the Warehouse project using EF5 and some repositories from the test project and the MVC application.

The testing project works and can easily receive and update the database.

However, the MVC web project throws "Unable to find the requested .Net Framework data provider. It may not be installed." an error that I do not understand, because it uses the same connection string as the test project.

[ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.] System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) +1426271 WebMatrix.Data.DbProviderFactoryWrapper.CreateConnection(String connectionString) +64 WebMatrix.Data.<>c__DisplayClass15.<OpenConnectionStringInternal>b__14() +16 WebMatrix.Data.Database.get_Connection() +19 WebMatrix.Data.Database.EnsureConnectionOpen() +12 WebMatrix.Data.Database.QueryValue(String commandText, Object[] args) +63 WebMatrix.WebData.DatabaseWrapper.QueryValue(String commandText, Object[] parameters) +14 WebMatrix.WebData.SimpleMembershipProvider.GetUserId(IDatabase db, String userTableName, String userNameColumn, String userIdColumn, String userName) +232 WebMatrix.WebData.SimpleMembershipProvider.ValidateUserTable() +85 

I have...

  • Register System.Data.SqlClient in the web.config file.
  • Checked that a registered version (2.0.0.0) of System.Data exists in the GAC for this article.
  • Make sure there are no typos in the connection string.

Here is what I have in web.config ...

  <connectionStrings> <add name="DBCatalogContext" connectionString="metadata=res://*/DBCatalog.csdl| res://*/DBCatalog.ssdl| res://*/DBCatalog.msl; provider=System.Data.SqlClient; provider connection string=&quot;data source=.\SQLEXPRESS; initial catalog=DBCatalog; integrated security=True; multipleactiveresultsets=True; App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> </connectionStrings> <system.data> <DbProviderFactories> <add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> </DbProviderFactories> </system.data> 

The only thing I see that it makes no sense to me when I select the "System.Data" link in the "Links" folder and look at the properties that it says that it is version 4.0.0.0, but when I change the version in the section "DbProviderFactories" on the configuration site, I still get the error. Also, I don’t even see the link to this library in the Test project, which works.

I am sure that this is supervision or that I am missing any configuration settings, but I do not know where else to look at this point, so any help would be appreciated.

Thanks G

+4
source share
2 answers

I apparently left some, eventually, relevant information when I was originally published. This included the fact that the error was caused by membership services; in particular ... SimpleMembershipInitializer ... initially this class specified a connection string ... "DefaultConnection", defined in the web.config file, which will be used to initialize the connection to the database.

 WebSecurity.InitializeDatabaseConnection("DefaultConnection", "Users", "UserId", "UserName", autoCreateTables: false); 

I changed it to use the "DBCatalogContext" connection string that I added to web.config, believing that I would use this single connection string instead. The problem, of course, is that the new connection string I added was an Entity Framework connection string that the membership services did not recognize, which led to a data provider error.

I just added the original, regular connection string, in addition to the Entity Framework connection string, and now everything works. Well, everything related to this problem ...

 <connectionStrings> <add name="DBCatalogContext" connectionString="metadata=res://*/DBCatalog.csdl| res://*/DBCatalog.ssdl| res://*/DBCatalog.msl; provider=System.Data.SqlClient; provider connection string=&quot;data source=.\SQLEXPRESS; initial catalog=DBCatalog; integrated security=True; multipleactiveresultsets=True; App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="data source=.\SQLEXPRESS;initial catalog=DBCatalog;integrated security=True;multipleactiveresultsets=True;App=EntityFramework" /> </connectionStrings> 

I hope someone else finds this helpful.

+5
source

I had the same problems. I do the following: I extended the UserProfile model to get a new property, Email .

I should also add an Email column to this call:

 WebSecurity.InitializeDatabaseConnection("AgileBoardDB", "UserProfile", "UserId", "UserName", "Email", autoCreateTables: true); 

It never worked, I always get "... Provider not found". I tried everything with no luck.

I found out that EF is smart enough and automatically creates an Email column, so I removed the optional Email parameter from WebSecurity.InitializeDatabaseConnection , and now everything works fine.

PS: I use the same EF connection string to connect to my database.

0
source

All Articles