I was using an .mdf
for connecting to a database
and entityClient
. Now I want to change the connection string so that there will be no .mdf
file.
Is the following connectionString
correct?
<connectionStrings>
<!--<add name="conString" connectionString="metadata=res://*/conString.csdl|res://*/conString.ssdl|res://*/conString.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQL2008;AttachDbFilename=|DataDirectory|\NData.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />-->
<add name="conString" connectionString="metadata=res://*/conString.csdl|res://*/conString.ssdl|res://*/conString.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQL2008;Initial Catalog=NData;Integrated Security=True;Connect Timeout=30;User Instance=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
Because I always get the error:
The underlying provider failed on Open
I had this problem because the Application Pool login this app was running under had changed.
In IIS:
Find the Application pool by clicking on your site and going to Basic Settings.
Go to Application Pools.
Click on your site's application pool.
Click on Advanced Settings.
In Identity, enter account login and password.
Restart your site and try again.
This can also happen if you restore a database and the user already exists with different schema, leaving you unable to assign the correct permissions.
To correct this run:
The SQL Server Express service were not set tostart automatically.
1) Go to control panel 2) Administrative Tools 3) Service 4) Set SQL Server express to start automatically by clicking on it 5) Right click and start the service
I hope that will help.
I had the same issue few days ago, using "Integrated Security=True;" in the connection string you need to run the application pool identity under "localsystem" Sure this is not recommended but for testing it does the job.
This is how you can change the identity in IIS 7: http://www.iis.net/learn/manage/configuring-security/application-pool-identities
I had the same problem but what worked for me was removing this from the Connection String:
persist security info=True
I found the problem was that I had the server path within the connection string in one of these variants:
When really I should have:
For some reason I got the error whenever it had difficulty locating the instance of SQL.