| | |
| | | //using Bro.Process.Model.Migrations; |
| | | //using Bro.Process.Model.Model; |
| | | //using System; |
| | | //using System.Data.Entity; |
| | | //using System.Data.Entity.ModelConfiguration.Conventions; |
| | | //using System.Linq; |
| | | using Bro.M071.Model.Migrations; |
| | | using Bro.M071.Model.Model; |
| | | using System.Data.Entity; |
| | | using System.Data.Entity.ModelConfiguration.Conventions; |
| | | |
| | | //namespace Bro.M071.Model |
| | | //{ |
| | | // public class DBModel : DbContext |
| | | // { |
| | | // //您的上下文已配置为从您的应用程序的配置文件(App.config 或 Web.config) |
| | | // //使用“DBModel”连接字符串。默认情况下,此连接字符串针对您的 LocalDb 实例上的 |
| | | // //“Bro.Process.Model.DBModel”数据库。 |
| | | // // |
| | | // //如果您想要针对其他数据库和/或数据库提供程序,请在应用程序配置文件中修改“DBModel” |
| | | // //连接字符串。 |
| | | // public DBModel() |
| | | // : base("name=DataBase") |
| | | // { |
| | | // ////数据库迁移检查暂时放在构造函数中,回头会放到程序初始化中 |
| | | // //Database.SetInitializer(new MigrateDatabaseToLatestVersion<DBModel, Configuration>()); |
| | | // } |
| | | namespace Bro.M071.Model |
| | | { |
| | | public class DBModel : DbContext |
| | | { |
| | | //您的上下文已配置为从您的应用程序的配置文件(App.config 或 Web.config) |
| | | //使用“DBModel”连接字符串。默认情况下,此连接字符串针对您的 LocalDb 实例上的 |
| | | //“Bro.Process.Model.DBModel”数据库。 |
| | | // |
| | | //如果您想要针对其他数据库和/或数据库提供程序,请在应用程序配置文件中修改“DBModel” |
| | | //连接字符串。 |
| | | public DBModel() |
| | | : base("name=DataBase") |
| | | { |
| | | ////数据库迁移检查暂时放在构造函数中,回头会放到程序初始化中 |
| | | //Database.SetInitializer(new MigrateDatabaseToLatestVersion<DBModel, Configuration>()); |
| | | } |
| | | |
| | | // //为您要在模型中包含的每种实体类型都添加 DbSet。有关配置和使用 Code First 模型 |
| | | // //的详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkId=390109。 |
| | | |
| | | // // public virtual DbSet<MyEntity> MyEntities { get; set; } |
| | | // //public virtual DbSet<PRODUCTION_SECRETKEY> PRODUCTION_SECRETKEY { get; set; } |
| | | // //public virtual DbSet<PRODUCTION_CONFIG> PRODUCTION_CONFIG { get; set; } |
| | | //为您要在模型中包含的每种实体类型都添加 DbSet。有关配置和使用 Code First 模型 |
| | | //的详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkId=390109。 |
| | | |
| | | |
| | | // public virtual DbSet<ProductionDetectionRecords> ProductionDetectionRecords { get; set; } |
| | | // public virtual DbSet<ProductionDetectionRecordsDetail> ProductionDetectionRecordsDetail { get; set; } |
| | | // public virtual DbSet<OperationRecords> OperationRecords { get; set; } |
| | | // public virtual DbSet<ProductionDetectionImageRecords> ProductionDetectionImageRecords { get; set; } |
| | | // public virtual DbSet<ManualDetectionRecords> ManualDetectionRecords { get; set; } |
| | | // public virtual DbSet<EventTimeRecords> EventTimeRecords { get; set; } |
| | | public virtual DbSet<KeyUnitData> KeyUnitData { get; set; } |
| | | public virtual DbSet<MeasurementAndKeyDataRelation> MeasurementAndKeyDataRelation { get; set; } |
| | | public virtual DbSet<MeasurementUnitResult> MeasurementUnitResult { get; set; } |
| | | public virtual DbSet<ProductionMeasurementRecords> ProductionMeasurementRecords { get; set; } |
| | | |
| | | // protected override void OnModelCreating(DbModelBuilder modelBuilder) |
| | | // { |
| | | // //base.OnModelCreating(modelBuilder); |
| | | protected override void OnModelCreating(DbModelBuilder modelBuilder) |
| | | { |
| | | //base.OnModelCreating(modelBuilder); |
| | | #region for sqlite db |
| | | modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); |
| | | modelBuilder.Configurations.AddFromAssembly(typeof(DBModel).Assembly); |
| | | #endregion |
| | | } |
| | | } |
| | | |
| | | // #region for sqlite db |
| | | // modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); |
| | | // modelBuilder.Configurations.AddFromAssembly(typeof(DBModel).Assembly); |
| | | // #endregion |
| | | // } |
| | | // } |
| | | |
| | | // public static class DatabaseInitialize |
| | | // { |
| | | // public static void Initialize() |
| | | // { |
| | | // Database.SetInitializer(new MigrateDatabaseToLatestVersion<DBModel, Configuration>()); |
| | | // using (DbContext dbContext = new DBModel()) |
| | | // { |
| | | // dbContext.Database.Initialize(true); |
| | | // } |
| | | // } |
| | | // } |
| | | // //public class MyEntity |
| | | // //{ |
| | | // // public int Id { get; set; } |
| | | // // public string Name { get; set; } |
| | | // //} |
| | | //} |
| | | public static class DatabaseInitialize |
| | | { |
| | | public static void Initialize() |
| | | { |
| | | Database.SetInitializer(new MigrateDatabaseToLatestVersion<DBModel, Configuration>()); |
| | | using (DbContext dbContext = new DBModel()) |
| | | { |
| | | dbContext.Database.Initialize(true); |
| | | } |
| | | } |
| | | } |
| | | } |