| | |
| | | using FlexJobApi.Core; |
| | | using Furion; |
| | | using Furion.DatabaseAccessor; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using Microsoft.EntityFrameworkCore.Diagnostics; |
| | | using Microsoft.EntityFrameworkCore.Metadata.Builders; |
| | | using Microsoft.Extensions.Configuration; |
| | | using System; |
| | | |
| | | namespace FlexJobApi.EntityFramework.Core; |
| | |
| | | { |
| | | } |
| | | |
| | | public void OnCreating(ModelBuilder modelBuilder, EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator) |
| | | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) |
| | | { |
| | | DbUtils.OnCreating(modelBuilder, entityBuilder, dbContext, dbContextLocator); |
| | | base.OnConfiguring(optionsBuilder); |
| | | optionsBuilder |
| | | .UseSqlServer(App.Configuration.GetConnectionString("FlexJobApiLog"), options => |
| | | { |
| | | // 指定目标数据库版本为SQL Server 2014 |
| | | options.UseCompatibilityLevel(120); // 120对应SQL Server 2014 |
| | | // 可选:设置批量操作大小(按需调整) |
| | | options.MaxBatchSize(1000); |
| | | }); |
| | | } |
| | | |
| | | protected override void OnModelCreating(ModelBuilder modelBuilder) |
| | | { |
| | | base.OnModelCreating(modelBuilder); |
| | | DbUtils.BuildEntityComment(modelBuilder, typeof(LogDbContextLocator)).Wait(); |
| | | DbUtils.BuildEntity(modelBuilder, typeof(LogDbContextLocator)).Wait(); |
| | | } |
| | | |
| | | protected override void SavingChangesEvent(DbContextEventData eventData, InterceptionResult<int> result) |