public partial class WeighingSettlementModelContainer : DbContext
{
//不使用的默认构造函数,即dbContext(string nameOrConection)
//该构造函数只能读取数据库名或app.config文件中的conectionstring字符,
//若连接字符串加密,则无法使用,且该字符串中必须有providerName属性;
//故选择DbContext(DbConnection existingConnection, bool contextOwnsConnection)构造函数
//如此能构造sqlConnetion类读取app.config文件中的conectionstring的加密字符串(该连接字符串中可以
//省略providerName属性),并返回SqlConection
public WeighingSettlementModelContainer()
: base(Utility.Sql.Sqlhelper.sqlConnection(),true)
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
//throw new UnintentionalCodeFirstException();
}
public virtual DbSet<WeighingSettlement> WeighingSettlementSet { get; set; }
public virtual DbSet<Customer> CustomerSet { get; set; }
public virtual DbSet<Scrap> ScrapSet { get; set; }
}