I seem to have an issue creating an MVC4 application where I have adopted the code-first approach to creating my models but no connection string seems to have been created in the web.config file.
The constructed database seems to have been built on (localhost)\SQLEXPRESS instance but I would like to change this to an external data source. Without a connection string to update I'm not sure how to do this.
Please could someone point me in the right direction?
EDIT: I found the following diagram which highlights what the answers have said pretty well

(source: entityframeworktutorial.net)
You have to add a connection string yourself
<add name="SomeDb" connectionString="Data Source=SERVENAME;Initial Catalog=DBNAME;User Id=loginid;Password=password" providerName="System.Data.SqlClient" />
Name of this string should match to the name of your context class.
public class SomeDb: DbContext
{
public SomeDb()
: base("name=SomeDb")
{
}
}
This should do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With