C# 从.NET Core 2.2迁移到3.1时缺少“.Relational()”方法
我正在将一个项目从2.2更新到3.1,我有以下方法自动修补所有C# 从.NET Core 2.2迁移到3.1时缺少“.Relational()”方法,c#,asp.net-core,ef-core-3.0,C#,Asp.net Core,Ef Core 3.0,我正在将一个项目从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.Ge
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)");
而不是使用
property.Relational().ColumnType = "decimal(18, 6)";
你可以用
property.SetColumnType("decimal(18, 6)");
非常感谢你!非常感谢你!