53 lines
1.7 KiB
C#
53 lines
1.7 KiB
C#
using Crm.Core.Entity.Crm;
|
|
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 WeworkDbContext : DbContext
|
|
{
|
|
public WeworkDbContext(DbContextOptions<WeworkDbContext> 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<WwHhuser>()
|
|
.HasKey(x => new { x.Userid, x.Corpid });
|
|
|
|
modelBuilder.Entity<WwUserExtuser>()
|
|
.HasKey(x => new { x.Userid, x.Extuserid, x.Corpid });
|
|
|
|
base.OnModelCreating(modelBuilder);
|
|
}
|
|
|
|
public DbSet<WwCorp> WwCorp { get; set; }
|
|
|
|
public DbSet<WwExtuser> WwExtuser { get; set; }
|
|
|
|
public DbSet<WwHhuser> WwHhuser { get; set; }
|
|
|
|
public DbSet<WwUserExtuser> WwUserExtuser { get; set; }
|
|
|
|
public DbSet<BasConfig> BasConfig { get; set; }
|
|
}
|
|
}
|