Last active
March 20, 2018 12:25
-
-
Save anton-putau/52d881fb9874f8b9cd300638d3b120f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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="data Source=IP;initial catalog=Catalog;persist security info=True;user id=id;password=pwd;MultipleActiveResultSets=True;App=EntityFramework"" 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