从 .NET Core 2.2 迁移到 3.1 时缺少 .Relational() 方法
Missing `.Relational()` method when migration from .NET Core 2.2 to 3.1
我正在将一个项目从 2.2 更新到 3.1,我有以下方法自动修补所有 decimal
属性以在创建新迁移时使用 decimal(18, 6)
sql 类型。
public static void PatchDecimalProperties(this ModelBuilder builder)
{
foreach (var property in builder.Model.GetEntityTypes()
.SelectMany(t => t.GetProperties())
.Where(p => p.ClrType == typeof(decimal) || p.ClrType == typeof(decimal?)))
{
property.Relational().ColumnType = "decimal(18, 6)";
}
}
现在在 3.1 中 IMutableProperty.Relational()
方法不再存在。
这个方法还存在还是有替代方法?
而不是使用
property.Relational().ColumnType = "decimal(18, 6)";
你可以使用
property.SetColumnType("decimal(18, 6)");
我正在将一个项目从 2.2 更新到 3.1,我有以下方法自动修补所有 decimal
属性以在创建新迁移时使用 decimal(18, 6)
sql 类型。
public static void PatchDecimalProperties(this ModelBuilder builder)
{
foreach (var property in builder.Model.GetEntityTypes()
.SelectMany(t => t.GetProperties())
.Where(p => p.ClrType == typeof(decimal) || p.ClrType == typeof(decimal?)))
{
property.Relational().ColumnType = "decimal(18, 6)";
}
}
现在在 3.1 中 IMutableProperty.Relational()
方法不再存在。
这个方法还存在还是有替代方法?
而不是使用
property.Relational().ColumnType = "decimal(18, 6)";
你可以使用
property.SetColumnType("decimal(18, 6)");