Skip to content

Instantly share code, notes, and snippets.

@anton-putau
Last active March 20, 2018 12:25
Show Gist options
  • Save anton-putau/52d881fb9874f8b9cd300638d3b120f0 to your computer and use it in GitHub Desktop.
Save anton-putau/52d881fb9874f8b9cd300638d3b120f0 to your computer and use it in GitHub Desktop.
// current context implementation and config usage
public MembershipDbContext()
: base("ConnectionStringName", throwIfV1Schema: false)
{
Configuration.ProxyCreationEnabled = false;
Configuration.LazyLoadingEnabled = false;
}
// a lot of connection strings like this one
<add name="ConnectionStringName" connectionString="metadata=res://*/Infrastructure.DataModels.Entity.EntityViewsModel.csdl|res://*/Infrastructure.DataModels.Entity.EntityViewsModel.ssdl|res://*/Infrastructure.DataModels.Entity.EntityViewsModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data Source=IP;initial catalog=Catalog;persist security info=True;user id=id;password=pwd;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
// idea to reduce amount of configuration efforts
public MembershipDbContext()
: base(ConnectionStringBuilder.Build("Infrastructure.DataModels.Entity.EntityViewsModel"), throwIfV1Schema: false)
{
Configuration.ProxyCreationEnabled = false;
Configuration.LazyLoadingEnabled = false;
}
// only 1 - 2 patterns, easy to manage, less code, ...
<add key="connection string pattern" datasource="127.0.0.1" catalog="database_#VERSION" user="" ...../>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment