I am deploying an ASP.NET web app to Azure Web Sites.
The site uses Entity Framework, and when I include the following in Web.config it runs fine:
<connectionStrings>
<add name="DataContext" connectionString="metadata=res://*/Models.WpsData.csdl|res://*/Models.WpsData.ssdl|res://*/Models.WpsData.msl;provider=System.Data.SqlClient;provider connection string="data source=XXXX;initial catalog=XXXX;persist security info=True;user id=XXXX;password=XXXX;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
However, if this connection string is removed and instead specified via the Azure Management Portal, an error occurs.
Name: DataContext
Value: metadata=res://*/Models.WpsData.csdl|res://*/Models.WpsData.ssdl|res://*/Models.WpsData.msl;provider=System.Data.SqlClient;provider connection string="data source=XXXX;initial catalog=XXXX;persist security info=True;user id=XXXX;password=XXXX;multipleactiveresultsets=True;application name=EntityFramework"
Type: Custom
This results in the error: No connection string named 'DataContext' could be found in the application config file.
See similar question here.
Try leaving the connection string in web.config with some value (either some test connection string, or some dummy value) e.g.
<connectionStrings>
<add name="DataContext" connectionString="dummy" providerName="System.Data.EntityClient" />
</connectionStrings>
Related
How to write the connection string to local SQL Server database using web.config?
Here is my connection string in web.config. But when I open local/demo, it said:
login failed for user ''.
Actually I'm using Windows authentication, so I thought it doesn't need user and password.
<connectionStrings>
<add name="HRISContext"
connectionString="data source=.;initial catalog=BPSDEMO;Pooling=false;persist security info=True;user id=;password=;MultipleActiveResultSets=True;App=EntityFramework"
providerName="System.Data.SqlClient" />
</connectionStrings>
If you want to use Windows authentication, then yes, you must not include any user id and pwd in your connection string - just remove those completely. But you must include the Integrated Security=SSPI setting instead.
Try this:
<connectionStrings>
<add name="HRISContext"
connectionString="data source=.;initial catalog=BPSDEMO;Integrated Security=SSPI;MultipleActiveResultSets=True;Pooling=false;persist security info=True;App=EntityFramework"
providerName="System.Data.SqlClient" />
</connectionStrings>
I have IIS and SQL Server Express on the same machine. After deployment of web site to this environment I get this error:
Cannot open database "MyDB" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\USER'.
Here are my connection strings where I set SQL Server user
<connectionStrings>
<add name="myCS1"
connectionString="data source=172.20.3.20\SQLEXPRESS;initial catalog=MyDB;user id=SomeUser;password=SomeUser###;integrated security=True;MultipleActiveResultSets=True;"
providerName="System.Data.SqlClient" />
<add name="myCS2"
connectionString="metadata=res://*/CLModel.csdl|res://*/CLModel.ssdl|res://*/CLModel.msl;provider=System.Data.SqlClient;provider connection string="data source=172.20.3.20\SQLEXPRESS;initial catalog=myDB;persist security info=True;user id=SomeUser;password=SomeUser###;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>
I want to use SQL Server user for connection to the database but not AppPool user.
I specified login and password but it seems that this info is not taken in account and in error message I still see IIS user but not sql.
What I missed?
Well, you specify both - explicit user id and password, and Integrated Security=True - in your myCS1 connection string:
data source=172.20.3.20\SQLEXPRESS;initial catalog=MyDB;
user id=SomeUser;password=SomeUser###;integrated security=True;
In this case, the integrated security wins over your user - you need to specify only the user id and password and get rid of the integrated security - so use this:
<connectionStrings>
<add name="myCS1"
connectionString="data source=172.20.3.20\SQLEXPRESS;initial catalog=MyDB;user id=SomeUser;password=SomeUser###;MultipleActiveResultSets=True;"
providerName="System.Data.SqlClient" />
<add name="myCS2"
connectionString="metadata=res://*/CLModel.csdl|res://*/CLModel.ssdl|res://*/CLModel.msl;provider=System.Data.SqlClient;provider connection string="data source=172.20.3.20\SQLEXPRESS;initial catalog=myDB;persist security info=True;user id=SomeUser;password=SomeUser###;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>
Good evening. I have a asp.net mvc3 web project, with sql server database 2012 and EF5. This site working perfectly on my local machine, but when I upload this to Arvixe web hosting and try to connect to pages which connect to database they print me an error:
Could not determine storage version; a valid storage connection or a version hint is required.
I'm try 2 different connection string, but everything without success:
<add name="PrimaryConnectionString"
providerName="System.Data.SqlClient"
connectionString="Data Source=camellia.arvixe.com;Initial Catalog=MyDatabaseName;Integrated Security=false;User ID=userLogin;Password=userPassword;"/>
<add name="SecondaryConnectionString"
connectionString="Data Source=localhost;Initial Catalog=myDatabaseName;Persist Security Info=true;User ID=userLogin;Password=userPassword;"
providerName="System.Data.SqlClient" />
and in code I'm use next part of code to connect to database:
My Context class
public UniversityContext(string connectionString)
{
Database.Connection.ConnectionString = connectionString;
}
Connect from context in project
private UniversityContext context = new UniversityContext(ConfigurationManager.ConnectionStrings[1].ConnectionString);
I'll try to connect to support, but the're didn't know why isn't working, and I'm very embarrased, Have anyone ideas, because I'm in a blind alley.
Don't you have the ip for the database that they gave you?
i use arvixe too, and my db conn in the web.config goes like this:
<connectionStrings>
<add name="MyDBConnectionString" connectionString="Data Source=65.98.21.152;Initial Catalog=mydatabase;User ID=mydatabaseLogin;Password=010101" providerName="System.Data.SqlClient"/>
</connectionStrings>
Hope this helps
So I have the following in my local web.config file:
<connectionStrings>
<add name="orangefreshConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\orangefresh.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
<add name="orangefreshEntities" connectionString="metadata=res://*/App_Code.Orangefresh.csdl|res://*/App_Code.Orangefresh.ssdl|res://*/App_Code.Orangefresh.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\orangefresh.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
I uploaded my website to my host, created my database and attached the necessary files to it (the mdf file and the log file), running a query shows the database has all the right data and is working fine.
The host has given me the following connection string:
workstation id=orangefresh.mssql.somee.com;packet size=4096;user id=xxxx;pwd=xxxx;data source=orangefresh.mssql.somee.com;persist security info=False;initial catalog=orangefresh
(I blacked out the user/pass details)
This connection string, I'm guessing is the to replace the local "orangefreshConnectionString1" connection string, which I've done. Now I'm left wondering what to replace my Identity connection string with, the "orangefreshEntities" which makes use the Entity Framework.
This obviously results in error on the pages that make use of ADO, all the other pages work fine it seems. Any ideas on what to do with the Entity connection string?
Inside orangefreshEntities, you have a reference to connection string="data source=.\SQLEXPRESS;...
I would change that part with the new connection string.
For the rest you are good to go. Path to the csdl, msl and ssdl will not change.
Fixed:
<add name="orangefreshEntities" connectionString="metadata=res://*/App_Code.Orangefresh.csdl|res://*/App_Code.Orangefresh.ssdl|res://*/App_Code.Orangefresh.msl;provider=System.Data.SqlClient;provider connection string="workstation id=orangefresh.mssql.somee.com;packet size=4096;user id=xxxx;pwd=xxxx;data source=orangefresh.mssql.somee.com;persist security info=False;initial catalog=orangefresh"" providerName="System.Data.EntityClient" />
the trick was putting the connection string in between the $quot marks.
I'm running ASP.NET MVC on a shared server and I'm having problems connecting to SQL via System.Data.EntityClient. Below is the connection string that my hosing provider gave me to connect to SQL and the one that VS configured for my local machine during development, what should my connection string look like when I deploy to the server?
From my hosting provider:
<add name="WeddingsDBEntities"
connectionString="data Source=<server name>; Initial Catalog=<db name>; User ID=<user ID>; Password=<password>;"
providerName="System.Data.EntityClient"/>
From VS (during development):
connectionString="metadata=res://*/Models.WeddingsModel.csdl|res://*/Models.WeddingsModel.ssdl|res://*/Models.WeddingsModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\WeddingsDB.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"
Thanks!
You have to wrap the connection string instide an entity connection string which is in the format of
<add name="Name"
connectionString="metadata=<Conceptual Model>|<Store Model>|<Mapping Model>;
provider=<Underlying Connection Provider>;
provider connection string="<Underlying ConnectionString>""
providerName="System.Data.EntityClient"/>
Instead of:
<add name="WeddingsDBEntities"
connectionString="data Source=<server name>; Initial Catalog=<db name>; User ID=<user ID>; Password=<password>;"
providerName="System.Data.EntityClient"/>
Use this:
<add name="WeddingsDBEntities"
connectionString="metadata=res://*/Models.WeddingsModel.csdl|res://*/Models.WeddingsModel.ssdl|res://*/Models.WeddingsModel.msl;provider=System.Data.SqlClient;provider connection string="data Source=<server name>; Initial Catalog=<db name>; User ID=<user ID>; Password=<password>;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient"/>
Change the provider from entityclient to sqlclient (assume code first EF).
providerName="System.Data.EntityClient" />
to
providerName="System.Data.SqlClient" />
<add name="Name" connectionString="metadata=res://*; provider=System.Data.SqlClient; provider connection string='; data source=YOURIP;Initial Catalog=YOURDB;Persist Security Info=True;User ID=YOURUSER;Password=YOURPASSWORD; Connect Timeout=15;Encrypt=False;Packet Size=4096;MultipleActiveResultSets=True'"
providerName="System.Data.EntityClient"/>
Hope this Will help you!!