当我尝试使用带有未导航导航属性的codefirst生成数据库时,我收到错误:
错误0040:类型Point_Countries未在命名空间 xx.xxx (Alias = Self)中定义。
我有3个班级
public class PointBase
{
public int PointID { get; set; }
public virtual Point Point { get; set; }
}
public class Point
{
public int PointID { get; set; }
public DbGeography Data { get; set; }
public virtual ICollection<Country> Countries { get; set; }
}
public Country : PointBase
{
public int CountryID { get; set; }
public string Name { get; set; }
}
之后,我为点
创建了一个EntityTypeConfigurationinternal class PointMap : EntityTypeConfiguration<Point>
{
public PointMap()
{
HasMany(x => x.Countries).WithRequired(x => x.Point).HasForeignKey(x => x.PointID);
}
}
我似乎无法弄清楚为什么会出现这个错误...