0

I am having problem in running my ASP.Net MVC project which is an admin project. It connects with a sql server database to fetch record. When I try to build and run, I am welcomed with this error: "Unable to find requested .Net Framework Data Provider. It may not be installed". Here is the link to this error.

I have tried many solutions available on stackoverflow but none of them worked for me that's why I am posting this question here again. I tried changing the Target Framework version in Properties of project to all the available versions but all in vain. Here is the screenshot of my Global.asax.cs file which is causing this exception.

Below is the connection string of my project:

<add name="AlkhaleejEntities" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=Alkhaleej;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
ᴘᴀɴᴀʏɪᴏᴛɪs
  • 7,169
  • 9
  • 50
  • 81
Ali Raza
  • 374
  • 2
  • 6
  • 21
  • Did you try fresh install of Sql server provider as specified [here](https://msdn.microsoft.com/en-us/library/dn538994(v=sql.120).aspx) ? – Siva Gopal Jan 28 '17 at 19:15
  • Dear #SivaGopal ! I tried installing Sql Server provider from the link you provided, restarted my system and visual studio. Then I 've re-run my project but same exception is there once again :( . – Ali Raza Jan 29 '17 at 06:30
  • Did you already installed 'EntityFramework.SqlServerCompact'? Or you can provide us the list of things you tried that didn't work. – jomsk1e Jan 30 '17 at 10:09

1 Answers1

0

Connection string provided above indicates EF connection provider being used:

connectionString="metadata=res:///Models.Model1.csdl|res:///Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=Alkhaleej;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient"

Note that SimpleMembershipProvider can't use EF provider connection string (see this post) due to usage of SqlClient provider instead of EntityClient, hence it requires SQL Server connection string to interact with database.

Try open Server Explorer => Data Connections => right click your server connection, select Properties => add provided SQL Server connection string something like this one (leave EF connection string part as is, just add SqlClient provider connection string):

<add name="DefaultConnection" connectionString="Data Source=.;Initial Catalog=Alkhaleej;Integrated Security=True" providerName="System.Data.SqlClient" />

Then, change connectionStringName parameter on WebSecurity.InitializeDatabaseConnection method inside SimpleMembershipInitializer class to SQL Server connection string name as given below:

public class SimpleMembershipInitializer
{
    public SimpleMembershipInitializer()
    {
        // other code part

        if (!WebSecurity.Initialized)
        {
            WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "Email", autoCreateTables: true);
        }
    }
}

NB: The ideal setup for EF projects should include at least one SqlClient connection string and one EntityClient connection string, which may serve different providers with same target database.

Similar issues:

SimpleMembershipInitializer won't initialize

Unable to find the requested .Net Framework Data Provider. (SqlClient)

Can SimpleMembership and Entity Framework share a connection string?

Community
  • 1
  • 1
Tetsuya Yamamoto
  • 24,297
  • 8
  • 39
  • 61