我不熟悉开发,正在尝试创建一个小项目,对于这个问题,我很抱歉,我知道之前曾有人问过这个问题,但是我尝试阅读有关它,但未能解决我的问题,我有这个模型
public class DummyProject: BaseModel
{
public string X{ get; set; } = null!;
public string Y{ get; set; } = null!;
public string Z{ get; set; } = null!;
public string Q{ get; set; } = null!;
[ForeignKey(nameof(fooN))]
public Guid? FooId{ get; set; }
public Foo? FooN{ get; set; } = null;
}
public class Foo: BaseModel
{
public string P{ get; set; } = null!;
public string T{ get; set; } = null!;
}
我像这样将它们钩在DBcontect中
public DbSet<DummyProject> DummyProjects{ get; set; } = null!;
public DbSet<Foo> Foos{ get; set; } = null!;
并在Modelbuilder中添加了模型的每个实体
[当我尝试进行迁移并更新Db时,我得到外键约束错误
constraint "fk_dummy_projects_dummy_projectss_foon_id" of relation "dummy_projects" does not exist
而且我不知道这是否与错误有关,但是在foo模型上,我也警告过它永远不会被实例化