修复数据
This commit is contained in:
@@ -4,6 +4,7 @@ using Jiaowu.Api.Domain.Identity;
|
||||
using Jiaowu.Api.Domain.System;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace Jiaowu.Api.Infrastructure.Persistence;
|
||||
|
||||
@@ -90,6 +91,18 @@ public sealed class AppDbContext(DbContextOptions<AppDbContext> options)
|
||||
Set<GraduationClearanceRecord>();
|
||||
public DbSet<AuditLog> AuditLogs => Set<AuditLog>();
|
||||
|
||||
protected override void ConfigureConventions(
|
||||
ModelConfigurationBuilder configurationBuilder)
|
||||
{
|
||||
base.ConfigureConventions(configurationBuilder);
|
||||
|
||||
// Connector/NET returns MySQL DATE values as DateTime. An explicit
|
||||
// provider conversion prevents EF from asking the reader for DateOnly.
|
||||
configurationBuilder.Properties<DateOnly>()
|
||||
.HaveConversion<DateOnlyDateTimeConverter>()
|
||||
.HaveColumnType("date");
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
@@ -904,3 +917,8 @@ public sealed class AppDbContext(DbContextOptions<AppDbContext> options)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class DateOnlyDateTimeConverter()
|
||||
: ValueConverter<DateOnly, DateTime>(
|
||||
date => date.ToDateTime(TimeOnly.MinValue),
|
||||
value => DateOnly.FromDateTime(value));
|
||||
|
||||
Reference in New Issue
Block a user