53 lines
1.9 KiB
C#
53 lines
1.9 KiB
C#
using Crm.Core.Entity.Crm;
|
|
using Crm.Core.Entity.PcWework;
|
|
using Microsoft.EntityFrameworkCore.Diagnostics;
|
|
using Microsoft.Extensions.Logging;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.ConstrainedExecution;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Crm.Core.EntityFramework
|
|
{
|
|
public class PcWeworkDbContext : DbContext
|
|
{
|
|
public PcWeworkDbContext(DbContextOptions<PcWeworkDbContext> options) : base(options)
|
|
{
|
|
}
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development")
|
|
{
|
|
var loggerFactory = new LoggerFactory();
|
|
loggerFactory.AddProvider(new EFLoggerProvider());
|
|
optionsBuilder.UseLoggerFactory(loggerFactory);
|
|
}
|
|
optionsBuilder.ConfigureWarnings(b => b.Ignore(CoreEventId.ContextInitialized));
|
|
base.OnConfiguring(optionsBuilder);
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<PcWwUserExtuser>()
|
|
.HasKey(x => new { x.userid, x.extuserid });
|
|
|
|
modelBuilder.Entity<PcWwHhuser>()
|
|
.HasKey(x => new { x.userid, x.corpid });
|
|
modelBuilder.Entity<PcWwExtuser>()
|
|
.HasKey(x => new { x.userid, x.corpid });
|
|
modelBuilder.Entity<ww_grouptag>()
|
|
.HasKey(x => new { x.corpid , x.group_id });
|
|
base.OnModelCreating(modelBuilder);
|
|
}
|
|
|
|
public DbSet<PcWwUserExtuser> PcWwUserExtuser { get; set; }
|
|
|
|
public DbSet<PcWwHhuser> PcWwHhuser { get; set; }
|
|
|
|
public DbSet<PcWwExtuser> PcWwExtuser { get; set; }
|
|
public DbSet<ww_grouptag> ww_grouptag { get; set; }
|
|
}
|
|
} |