123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463 |
- using System;
- using System.Collections.Generic;
- using CodeFirstExistingDatabaseSample.ISMS_Data.Models;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.EntityFrameworkCore.Metadata;
- namespace CodeFirstExistingDatabaseSample
- {
- public partial class ISMS_DataContext : DbContext
- {
- public ISMS_DataContext()
- {
- }
- public ISMS_DataContext(DbContextOptions<ISMS_DataContext> options)
- : base(options)
- {
- }
- public virtual DbSet<ImAbnormalYxcount> ImAbnormalYxcounts { get; set; } = null!;
- public virtual DbSet<ImAlert200010> ImAlert200010s { get; set; } = null!;
- public virtual DbSet<ImAlert202407> ImAlert202407s { get; set; } = null!;
- public virtual DbSet<ImDeviceDataValue> ImDeviceDataValues { get; set; } = null!;
- public virtual DbSet<ImDzdataDetail> ImDzdataDetails { get; set; } = null!;
- public virtual DbSet<ImDzdataMain> ImDzdataMains { get; set; } = null!;
- public virtual DbSet<ImYcstat202407> ImYcstat202407s { get; set; } = null!;
- public virtual DbSet<ImYxdatum> ImYxdata { get; set; } = null!;
- public virtual DbSet<TbDataModiHi> TbDataModiHis { get; set; } = null!;
- public virtual DbSet<TbSession> TbSessions { get; set; } = null!;
- public virtual DbSet<TbXiTongRiZhi> TbXiTongRiZhis { get; set; } = null!;
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- if (!optionsBuilder.IsConfigured)
- {
- #warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
- optionsBuilder.UseSqlServer("Server=192.168.110.161;User ID=sa;Password=sa;Database=ISMS_Data;Trusted_Connection=False;");
- }
- }
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- modelBuilder.Entity<ImAbnormalYxcount>(entity =>
- {
- entity.HasKey(e => e.DeviceId)
- .HasName("PK_AbnormalYXCount");
- entity.ToTable("im_AbnormalYXCount");
- entity.Property(e => e.DeviceId)
- .HasMaxLength(7)
- .IsUnicode(false)
- .HasColumnName("DeviceID");
- entity.Property(e => e.LastConfirmTime)
- .HasMaxLength(30)
- .IsUnicode(false);
- });
- modelBuilder.Entity<ImAlert200010>(entity =>
- {
- entity.ToTable("im_Alert200010");
- entity.HasIndex(e => e.AlertTime, "Ind_im_Alert200010");
- entity.Property(e => e.Id)
- .HasMaxLength(38)
- .IsUnicode(false)
- .HasColumnName("ID");
- entity.Property(e => e.AlertDomain)
- .HasMaxLength(20)
- .IsUnicode(false)
- .HasDefaultValueSql("('系统')");
- entity.Property(e => e.AlertLevel)
- .HasMaxLength(10)
- .IsUnicode(false);
- entity.Property(e => e.AlertTime)
- .HasMaxLength(25)
- .IsUnicode(false);
- entity.Property(e => e.AlertType)
- .HasMaxLength(20)
- .IsUnicode(false);
- entity.Property(e => e.Alerter)
- .HasMaxLength(255)
- .IsUnicode(false);
- entity.Property(e => e.Content)
- .HasMaxLength(2500)
- .IsUnicode(false);
- entity.Property(e => e.DeviceId)
- .HasMaxLength(30)
- .IsUnicode(false)
- .HasColumnName("DeviceID");
- entity.Property(e => e.LnkType)
- .HasMaxLength(30)
- .IsUnicode(false);
- entity.Property(e => e.RecTime).HasColumnType("datetime");
- entity.Property(e => e.Reserved)
- .HasMaxLength(255)
- .IsUnicode(false);
- entity.Property(e => e.StatCode)
- .HasMaxLength(30)
- .IsUnicode(false);
- entity.Property(e => e.State)
- .HasMaxLength(10)
- .IsUnicode(false);
- entity.Property(e => e.TimeSrc)
- .HasMaxLength(8)
- .IsUnicode(false);
- });
- modelBuilder.Entity<ImAlert202407>(entity =>
- {
- entity.ToTable("im_Alert202407");
- entity.HasIndex(e => e.AlertTime, "Ind_im_Alert202407");
- entity.Property(e => e.Id)
- .HasMaxLength(38)
- .IsUnicode(false)
- .HasColumnName("ID");
- entity.Property(e => e.AlertDomain)
- .HasMaxLength(20)
- .IsUnicode(false)
- .HasDefaultValueSql("('系统')");
- entity.Property(e => e.AlertLevel)
- .HasMaxLength(10)
- .IsUnicode(false);
- entity.Property(e => e.AlertTime)
- .HasMaxLength(25)
- .IsUnicode(false);
- entity.Property(e => e.AlertType)
- .HasMaxLength(20)
- .IsUnicode(false);
- entity.Property(e => e.Alerter)
- .HasMaxLength(255)
- .IsUnicode(false);
- entity.Property(e => e.Content)
- .HasMaxLength(2500)
- .IsUnicode(false);
- entity.Property(e => e.DeviceId)
- .HasMaxLength(30)
- .IsUnicode(false)
- .HasColumnName("DeviceID");
- entity.Property(e => e.LnkType)
- .HasMaxLength(30)
- .IsUnicode(false);
- entity.Property(e => e.RecTime).HasColumnType("datetime");
- entity.Property(e => e.Reserved)
- .HasMaxLength(255)
- .IsUnicode(false);
- entity.Property(e => e.StatCode)
- .HasMaxLength(30)
- .IsUnicode(false);
- entity.Property(e => e.State)
- .HasMaxLength(10)
- .IsUnicode(false);
- entity.Property(e => e.TimeSrc)
- .HasMaxLength(8)
- .IsUnicode(false);
- });
- modelBuilder.Entity<ImDeviceDataValue>(entity =>
- {
- entity.HasKey(e => e.DataId)
- .HasName("PK_DeviceDataValue");
- entity.ToTable("im_DeviceDataValue");
- entity.Property(e => e.DataId)
- .HasMaxLength(12)
- .IsUnicode(false)
- .HasColumnName("DataID");
- entity.Property(e => e.OccTime).HasColumnType("datetime");
- entity.Property(e => e.TimeSrc)
- .HasMaxLength(8)
- .IsUnicode(false);
- entity.Property(e => e.Unit)
- .HasMaxLength(20)
- .IsUnicode(false);
- entity.Property(e => e.ValueStr)
- .HasMaxLength(30)
- .IsUnicode(false);
- });
- modelBuilder.Entity<ImDzdataDetail>(entity =>
- {
- entity.HasKey(e => e.DzdataDetailId)
- .HasName("PK_DZData_Detail");
- entity.ToTable("im_DZData_Detail");
- entity.HasIndex(e => new { e.DzdataMainId, e.DzId }, "UK_DZData_Detail")
- .IsUnique();
- entity.Property(e => e.DzdataDetailId)
- .HasMaxLength(40)
- .IsUnicode(false)
- .HasColumnName("DZDataDetailID");
- entity.Property(e => e.DzComment)
- .HasMaxLength(255)
- .IsUnicode(false)
- .HasColumnName("DZ_Comment");
- entity.Property(e => e.DzId)
- .HasMaxLength(10)
- .IsUnicode(false)
- .HasColumnName("DZ_ID");
- entity.Property(e => e.DzIndex).HasColumnName("DZ_Index");
- entity.Property(e => e.DzUnit)
- .HasMaxLength(30)
- .IsUnicode(false)
- .HasColumnName("DZ_Unit");
- entity.Property(e => e.DzValue)
- .HasMaxLength(100)
- .IsUnicode(false)
- .HasColumnName("DZ_Value");
- entity.Property(e => e.DzdataMainId)
- .HasMaxLength(40)
- .IsUnicode(false)
- .HasColumnName("DZDataMainID");
- entity.HasOne(d => d.DzdataMain)
- .WithMany(p => p.ImDzdataDetails)
- .HasForeignKey(d => d.DzdataMainId)
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("FK_DZData_Detail_Main");
- });
- modelBuilder.Entity<ImDzdataMain>(entity =>
- {
- entity.HasKey(e => e.DzdataMainId)
- .HasName("PK_DZData_Main");
- entity.ToTable("im_DZData_Main");
- entity.Property(e => e.DzdataMainId)
- .HasMaxLength(40)
- .IsUnicode(false)
- .HasColumnName("DZDataMainID");
- entity.Property(e => e.CpuIndex).HasColumnName("CPU_Index");
- entity.Property(e => e.CreateTime).HasColumnType("datetime");
- entity.Property(e => e.DataType)
- .HasMaxLength(20)
- .IsUnicode(false);
- entity.Property(e => e.DeviceId)
- .HasMaxLength(7)
- .IsUnicode(false)
- .HasColumnName("DeviceID");
- entity.Property(e => e.UserName)
- .HasMaxLength(50)
- .IsUnicode(false);
- });
- modelBuilder.Entity<ImYcstat202407>(entity =>
- {
- entity.HasKey(e => new { e.DataId, e.HourTime });
- entity.ToTable("im_YCStat202407");
- entity.Property(e => e.DataId)
- .HasMaxLength(12)
- .IsUnicode(false)
- .HasColumnName("DataID");
- entity.Property(e => e.HourTime).HasColumnType("datetime");
- entity.Property(e => e.BeiZhu)
- .HasMaxLength(255)
- .IsUnicode(false);
- entity.Property(e => e.MaxOccTime).HasColumnType("datetime");
- entity.Property(e => e.MinOccTime).HasColumnType("datetime");
- entity.Property(e => e.SeqNo).ValueGeneratedOnAdd();
- entity.Property(e => e.State)
- .HasMaxLength(10)
- .IsUnicode(false)
- .HasColumnName("State_")
- .HasDefaultValueSql("('有效')");
- });
- modelBuilder.Entity<ImYxdatum>(entity =>
- {
- entity.ToTable("im_YXData");
- entity.HasIndex(e => e.DataId, "Ind_im_YXData_DataID");
- entity.HasIndex(e => e.OccTime, "Ind_im_YXData_OccTime");
- entity.HasIndex(e => new { e.DataId, e.OccTime }, "UK_YXData")
- .IsUnique();
- entity.Property(e => e.Id).HasColumnName("ID");
- entity.Property(e => e.Comment)
- .HasMaxLength(500)
- .IsUnicode(false);
- entity.Property(e => e.CreateTime)
- .HasColumnType("datetime")
- .HasDefaultValueSql("(getdate())");
- entity.Property(e => e.DataId)
- .HasMaxLength(12)
- .IsUnicode(false)
- .HasColumnName("DataID");
- entity.Property(e => e.NormalOrNot)
- .HasMaxLength(20)
- .IsUnicode(false)
- .HasDefaultValueSql("('未知')");
- entity.Property(e => e.OccTime)
- .HasMaxLength(25)
- .IsUnicode(false);
- });
- modelBuilder.Entity<TbDataModiHi>(entity =>
- {
- entity.ToTable("tb_DataModiHis");
- entity.HasIndex(e => e.DstTable, "Ind_DataModiHis_DstTable");
- entity.HasIndex(e => e.EditTime, "Ind_DataModiHis_EditTime");
- entity.HasIndex(e => e.Editor, "Ind_DataModiHis_Editor");
- entity.HasIndex(e => e.Type, "Ind_DataModiHis_Type");
- entity.Property(e => e.Id).HasColumnName("ID");
- entity.Property(e => e.Content).IsUnicode(false);
- entity.Property(e => e.DstObjId)
- .HasMaxLength(255)
- .IsUnicode(false)
- .HasColumnName("DstObjID");
- entity.Property(e => e.DstObjName)
- .HasMaxLength(255)
- .IsUnicode(false);
- entity.Property(e => e.DstTable)
- .HasMaxLength(255)
- .IsUnicode(false);
- entity.Property(e => e.EditTime)
- .HasColumnType("datetime")
- .HasDefaultValueSql("(getdate())");
- entity.Property(e => e.Editor)
- .HasMaxLength(50)
- .IsUnicode(false);
- entity.Property(e => e.Type)
- .HasMaxLength(20)
- .IsUnicode(false);
- entity.Property(e => e.Upd20200410)
- .HasMaxLength(1)
- .IsUnicode(false);
- });
- modelBuilder.Entity<TbSession>(entity =>
- {
- entity.HasKey(e => e.SessionId)
- .HasName("PK_Session");
- entity.ToTable("tb_Session");
- entity.Property(e => e.SessionId)
- .HasMaxLength(255)
- .IsUnicode(false);
- entity.Property(e => e.ClientIp)
- .HasMaxLength(50)
- .IsUnicode(false)
- .HasColumnName("ClientIP");
- entity.Property(e => e.LastTime)
- .HasColumnType("datetime")
- .HasDefaultValueSql("(getdate())");
- entity.Property(e => e.SoftInfo)
- .HasMaxLength(2000)
- .IsUnicode(false);
- entity.Property(e => e.UserName)
- .HasMaxLength(50)
- .IsUnicode(false);
- });
- modelBuilder.Entity<TbXiTongRiZhi>(entity =>
- {
- entity.ToTable("tb_XiTongRiZhi");
- entity.Property(e => e.Id).HasColumnName("ID");
- entity.Property(e => e.FaShengRiQi)
- .HasMaxLength(10)
- .IsUnicode(false);
- entity.Property(e => e.FaShengShiJian)
- .HasMaxLength(5)
- .IsUnicode(false);
- entity.Property(e => e.MiaoShu)
- .HasMaxLength(255)
- .IsUnicode(false);
- entity.Property(e => e.YongHu)
- .HasMaxLength(20)
- .IsUnicode(false);
- });
- OnModelCreatingPartial(modelBuilder);
- }
- partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
- }
- }
|