46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using DG.EntityFramework;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Diagnostics;
|
|
using Microsoft.Extensions.Logging;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Zxd.Entity.dg;
|
|
|
|
namespace Zxd.EntityFramework
|
|
{
|
|
|
|
public class DgDbContext : DbContext
|
|
{
|
|
public DgDbContext(DbContextOptions<DgDbContext> 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)
|
|
{
|
|
|
|
}
|
|
|
|
public DbSet<Sms_Records> Sms_Records { get; set; }
|
|
public DbSet<Sms_Channel> Sms_Channel { get; set; }
|
|
|
|
|
|
|
|
}
|
|
}
|