I added a Security Token Service project to my solution using the federation utility. I then added an aspnetdb.mdb file to my project for sqlmembershipprovider store.
When I view and test my connection in the Server Explorer my connection succeeds. However when I run the solution I get an error: 26, A network-related or instance-specific error occurred while establishing a connection to SQL Server.
What am I doing wrong? How can I solve this?
<add name="connectionstring"
connectionString="Data Source=.;AttachDbFilename='C:\ClaimsEnableWebsite\ClaimsEnableWebSite_STS\App_Data\ASPNETDB.MDF';Integrated Security=True;User Instance=False;Context Connection=False"
providerName="System.Data.SqlClient" />
Edit >> Answer:
Connections to SQL Server database files (.mdf) require SQL Server Express to be installed and running on the local computer.
As you’ve found out, on any “real” version of SQL Server, you cannot use the
AttachDbFileName=approach – this is really only intended for development work using a SQL Server Express edition.You can however use the ASP.NET SQL Server Registration Tool (
aspnet_regsql) that’s installed with your .NET framework into a folder something likeC:\Windows\Microsoft.NET\Framework\v4.0.30319(substitute your current .NET framework version, if needed) to create those tables in any SQL Server database of your choice.See MSDN docs on the ASP.NET SQL Server registration tool for details.