Entity Framework 6: Specifying a ConnectionString in Code
I’ve been working recently with Entity Framework 6. So far I find it pleasant enough, although not as intuitive (at least for me) as the likes of NHibernate.
One of the things I wanted to do was to determine the connection string in code, rather than specifying it in my web.config file. You can use the following code snippet to set your connection string.
public class MyContext : DbContext
public MyContext() : base()
Database.Connection.ConnectionString = myAlternateConnectionString;