I am starting an MVC web app, using the new Asp.Net Identity bits, and will be using Entity Framework.
Identity requires a "normal" connection string as follows:
<add name="DefaultConnection" connectionString="data source=.;initial catalog=MyDB;integrated security=True;" providerName="System.Data.SqlClient" />
and Entity Framework comes out of the box with a connection string like this:
<add name="MyDBEntities" connectionString="metadata=res://*/Data.MyApp.csdl|res://*/Data.MyApp.ssdl|res://*/Data.MyApp.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=MyDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
I don't want to maintain 2 connection strings in my Web.Config.
My EF DBContext generated class looks like this:
public partial class MyDBEntities : DbContext
{
public MyDBEntities()
: base("name=MyDBEntities")
{
}
What is the simplest way to instantiate MyDBEntities using the DefaultConnection connectionstring? I understand that EF needs some of that extra stuff of course, and I appreciate there are programmatic ways to build the connection.
Do I need to create a separate partial class with a constructor so that it won't get blown away when I regenerate from the DB?
thanks!