Unable to connect to SQL Server database
asp.net-4.5, asp.net-mvc-4
Solution
Set these in your web.config
<membership defaultProvider="SqlMembershipProvider">
<providers>
<add
name="SqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="MusicStoreEntities"
/>
</providers>
</membership>
Roles
<roleManager defaultProvider ="SqlRoleProvider" >
<providers>
<add
name="SqlRoleProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="MusicStoreEntities"
/>
</providers>
</roleManager>
see http://msdn.microsoft.com/en-us/library/ms731049.aspx for more info
p.s. nicked the example from here
Problem
I'm creating a web application in mvc 4.0 and I need to enable Membership and Authorization using Asp.netWeb Site Administration Tool but when I clicks the security tab it gives me an error There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store. The following message may help in diagnosing the problem: Unable to connect to SQL Server database. and my connection string is given below ``` <connectionStrings> <add name="MusicStoreEntities" connectionString="Data Source=|DataDirectory|MvcMusicStore.sdf" providerName="System.Data.SqlClient"/> </connectionStrings> ``` I cant find any error in the code so please help me