[英]Missing `.Relational()` method when migration from .NET Core 2.2 to 3.1
[英]Missing `.Relational()` method when update .NET Core 2.2 to 3.1
我在 EF Core 2 中使用此代碼,現在嘗試更新 EF Core 並且找不到關系
public static void AddDefaultValueSqlConvention(this ModelBuilder modelBuilder, string propertyName,TypepropertyType, string defaultValueSql)
{
foreach (IMutableEntityType entityType in modelBuilder.Model.GetEntityTypes())
{
IMutableProperty property = entityType.GetProperties()
.SingleOrDefault(p => p.Name.Equals(propertyName, StringComparison.OrdinalIgnoreCase));
if (property != null && property.ClrType == propertyType)
property.SetColumnType().DefaultValueSql = defaultValueSql;
}
}
嘗試這個:
public static void AddDefaultValueSqlConvention(this ModelBuilder modelBuilder, string propertyName, Type propertyType, string defaultValueSql)
{
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
{
var property = entityType.GetProperties().SingleOrDefault(p => p.Name.Equals(propertyName, StringComparison.OrdinalIgnoreCase));
if (property != null && property.ClrType == propertyType)
property.SetDefaultValueSql(defaultValueSql);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.