43 lines
1.8 KiB
C#
43 lines
1.8 KiB
C#
using common;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace model
|
|
{
|
|
public class DataContext : DbContext
|
|
{
|
|
|
|
public DataContext()
|
|
{
|
|
}
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
optionsBuilder.UseMySql(ConfigHelper.GetSectionValue("ConnectionStrings:mysql"), new MySqlServerVersion("8.0"));
|
|
}
|
|
public virtual DbSet<ww_corp> ww_corps { get; set; }
|
|
public virtual DbSet<ww_dept> ww_depts { get; set; }
|
|
public virtual DbSet<ww_hhuser> ww_hhusers { get; set; }
|
|
public virtual DbSet<ww_extuser> ww_extusres { get; set; }
|
|
public virtual DbSet<ww_user_extuser> ww_user_extusers { get; set; }
|
|
public virtual DbSet<ww_userinfo> ww_userinfos { get; set; }
|
|
public virtual DbSet<ww_addway> ww_addways { get; set; }
|
|
public virtual DbSet<ww_grouptag> ww_grouptags { get; set; }
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<ww_dept>().HasKey(x => new { x.deptid, x.corpid });
|
|
modelBuilder.Entity<ww_grouptag>().HasKey(x => new { x.group_id, x.corpid });
|
|
modelBuilder.Entity<ww_hhuser>().HasKey(x => new { x.corpid, x.userid });
|
|
modelBuilder.Entity<ww_extuser>().HasKey(x => new { x.corpid, x.userid });
|
|
modelBuilder.Entity<ww_user_extuser>().HasKey(x => new { x.userid, x.extuserid });
|
|
modelBuilder.Entity<ww_userinfo>().HasKey(x => new { x.machineid, x.userid });
|
|
modelBuilder.Entity<ww_grouptag>().HasKey(x => new { x.corpid, x.group_id });
|
|
base.OnModelCreating(modelBuilder);
|
|
}
|
|
}
|
|
}
|