BaseDbContext.cs
2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using System.Data.SqlClient;
using Hh.Mes.Common;
using Hh.Mes.Common.config;
namespace WebRepository
{
public sealed class BaseDBContext : DbContext
{
public BaseDBContext(DbContextOptions<BaseDBContext> options) : base(options)
{
var connectionStrings = ConfigRead.GetInstance.GetAppsetConnection();
Database.GetDbConnection().ConnectionString = connectionStrings.BaseDBContext;
}
public DbSet<SysJob> SysJobs { get; set; }
public DbSet<SysCount> SysCounts { get; set; }
public DbSet<SysDept> SysDepts { get; set; }
public DbSet<SysInfo> SysInfos { get; set; }
public DbSet<SysModule> SysModules { get; set; }
public DbSet<SysModuleElement> SysModuleElements { get; set; }
public DbSet<SysRelevance> SysRelevances { get; set; }
public DbSet<SysRole> SysRoles { get; set; }
public DbSet<SysUser> SysUsers { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<SysCount>().HasKey(c => c.Type);
modelBuilder.Entity<SysCount>().Property(c => c.Type).HasColumnName("Type");
modelBuilder.Entity<SysDept>().HasKey(c => c.Id);
modelBuilder.Entity<SysDept>().Property(c => c.Id).HasColumnName("id");
modelBuilder.Entity<SysInfo>().HasKey(c => c.Id);
modelBuilder.Entity<SysInfo>().Property(c => c.Id).HasColumnName("id");
modelBuilder.Entity<SysModule>().HasKey(c => c.Id);
modelBuilder.Entity<SysModule>().Property(c => c.Id).HasColumnName("id");
modelBuilder.Entity<SysModuleElement>().HasKey(c => c.Id);
modelBuilder.Entity<SysModuleElement>().Property(c => c.Id).HasColumnName("id");
modelBuilder.Entity<SysRelevance>().HasKey(c => c.Id);
modelBuilder.Entity<SysRelevance>().Property(c => c.Id).HasColumnName("id");
modelBuilder.Entity<SysRole>().HasKey(c => c.Id);
modelBuilder.Entity<SysRole>().Property(c => c.Id).HasColumnName("id");
modelBuilder.Entity<SysUser>().HasKey(c => c.Id);
modelBuilder.Entity<SysUser>().Property(c => c.Id).HasColumnName("id");
modelBuilder.Entity<SysJob>().HasKey(c => c.Id);
modelBuilder.Entity<SysJob>().Property(c => c.Id).HasColumnName("id");
}
}
}