Mini.Crm/Mini.Model/wxContext.cs

54 lines
1.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Microsoft.EntityFrameworkCore;
using Mini.Common;
using Mini.Model.WxEntity;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
namespace Mini.Model
{
public class wxContext : DbContext
{
public wxContext(DbContextOptions<wxContext> options) : base(options)
{
}
public wxContext()
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseMySQL(Utility.GetSettingByKey("ConnectionStrings:wxContext"));
base.OnConfiguring(optionsBuilder);
}
public DbSet<Wx_WorkAccount> Wx_WorkAccount { get; set; }
public DbSet<Wx_Alive> Wx_Alive { get; set; }
public DbSet<Wx_JobuserLastFriend> Wx_JobuserLastFriend { get; set; }
public DbSet<Wx_LastMsgTime> Wx_LastMsgTime { get; set; }
public DbSet<Mini.Model.WxEntity.Bas_Parameter> Bas_Parameter { get; set; }
public DbSet<Mini.Model.WxEntity.Wx_Rcontact> Wx_Rcontact { get; set; }
//自定义DbContext实体属性名与数据库表对应名称默认 表名与属性名对应是 User与Users
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Wx_WorkAccount>().ToTable("Wx_WorkAccount".ToLower());
modelBuilder.Entity<Wx_Alive>().ToTable("Wx_Alive".ToLower());
modelBuilder.Entity<Wx_JobuserLastFriend>().ToTable("Wx_JobuserLastFriend".ToLower());
modelBuilder.Entity<Wx_LastMsgTime>().ToTable("Wx_LastMsgTime".ToLower());
modelBuilder.Entity<Mini.Model.WxEntity.Bas_Parameter>().ToTable("Bas_Parameter".ToLower());
modelBuilder.Entity<Mini.Model.WxEntity.Wx_Rcontact>().ToTable("Wx_Rcontact".ToLower());
base.OnModelCreating(modelBuilder);
}
}
}