修复数据
This commit is contained in:
@@ -13,10 +13,7 @@ public sealed class MySqlMigrationTests
|
||||
[Fact]
|
||||
public void Production_migration_is_discoverable_and_generates_mysql_sql()
|
||||
{
|
||||
var options = new DbContextOptionsBuilder<AppDbContext>()
|
||||
.UseMySQL(
|
||||
"Server=localhost;Database=jiaowu;User=__test__;Password=__not_used__;")
|
||||
.Options;
|
||||
var options = CreateMySqlOptions();
|
||||
using var db = new AppDbContext(options);
|
||||
|
||||
Assert.Contains(LatestMigration, db.Database.GetMigrations());
|
||||
@@ -33,4 +30,31 @@ public sealed class MySqlMigrationTests
|
||||
Assert.DoesNotContain("0001-01-01", script);
|
||||
Assert.DoesNotContain("0000-00-00", script);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MySql_date_properties_use_datetime_provider_conversion()
|
||||
{
|
||||
using var db = new AppDbContext(CreateMySqlOptions());
|
||||
|
||||
var dateProperties = db.Model.GetEntityTypes()
|
||||
.SelectMany(x => x.GetProperties())
|
||||
.Where(x => x.ClrType == typeof(DateOnly) ||
|
||||
x.ClrType == typeof(DateOnly?))
|
||||
.ToList();
|
||||
|
||||
Assert.NotEmpty(dateProperties);
|
||||
Assert.All(dateProperties, property =>
|
||||
{
|
||||
Assert.Equal("date", property.GetColumnType());
|
||||
Assert.Equal(
|
||||
typeof(DateTime),
|
||||
property.GetTypeMapping().Converter?.ProviderClrType);
|
||||
});
|
||||
}
|
||||
|
||||
private static DbContextOptions<AppDbContext> CreateMySqlOptions() =>
|
||||
new DbContextOptionsBuilder<AppDbContext>()
|
||||
.UseMySQL(
|
||||
"Server=localhost;Database=jiaowu;User=__test__;Password=__not_used__;")
|
||||
.Options;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user