【发布时间】:2020-11-17 11:26:33
【问题描述】:
下面是我的课
class Company
{
public int Id { get; set; }
public string Name { get; set; }
public Address Address { get; set; }
}
public class Address
{
public string Street { get; set; }
public int? CityId { get; set; }
public City City { get; set; }
public int CountryId { get; set; }
public Country Country { get; set; }
}
public class City
{
public int Id { get; set; }
public string Name { get; set; }
}
我的问题是:
-
我可以将 Address 类设为 OwnedType,因为 City id 是可选的
-
如果我将 Address 设为拥有类型,那么我的 City 类也需要拥有类型?
提前致谢使用 ef 核心 3.1
【问题讨论】: