2021-08-23 19:30:52 +08:00
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Sample.MySql.Domain.Maps;
|
2021-10-11 20:58:55 +08:00
|
|
|
|
using ShardingCore.Core.VirtualRoutes.TableRoutes.RouteTails.Abstractions;
|
2021-08-23 19:30:52 +08:00
|
|
|
|
using ShardingCore.Sharding;
|
2021-10-11 20:58:55 +08:00
|
|
|
|
using ShardingCore.Sharding.Abstractions;
|
2021-08-23 19:30:52 +08:00
|
|
|
|
|
|
|
|
|
namespace Sample.MySql.DbContexts
|
|
|
|
|
{
|
2021-10-11 20:58:55 +08:00
|
|
|
|
public class DefaultShardingDbContext:AbstractShardingDbContext, IShardingTableDbContext
|
2021-08-23 19:30:52 +08:00
|
|
|
|
{
|
|
|
|
|
public DefaultShardingDbContext(DbContextOptions<DefaultShardingDbContext> options) : base(options)
|
|
|
|
|
{
|
2022-01-18 11:22:12 +08:00
|
|
|
|
//切记不要在构造函数中使用会让模型提前创建的方法
|
|
|
|
|
//ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
|
2022-01-24 16:12:20 +08:00
|
|
|
|
//Database.SetCommandTimeout(30000);
|
2021-08-23 19:30:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
base.OnModelCreating(modelBuilder);
|
|
|
|
|
modelBuilder.ApplyConfiguration(new SysUserModMap());
|
|
|
|
|
modelBuilder.ApplyConfiguration(new SysTestMap());
|
|
|
|
|
modelBuilder.ApplyConfiguration(new SysUserLogByMonthMap());
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 20:58:55 +08:00
|
|
|
|
public IRouteTail RouteTail { get; set; }
|
2021-08-23 19:30:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|