I am trying to create a one-to-one relationship in EF Core using Fluent API but when I try to save the model it throws invalid column name exception.
public partial class Child
{
public Guid? ParentId {get;set;} // this is the FK
public virtual Parent {get;set;}
}
public partial class Parent
{
public Guid Id {get;set;}
public virtual Child {get;set;}
}
entity.HasOne(d => d.Child)
.WithOne(p => p.Parent)
.HasForeignKey<Child>(d => d.ParentId)
.HasConstraintName("FK_Parent_Child");
So when I try to save a Parent model to database I keep getting that ParentId
is an invalid column name( it does actually exist in the database, and I also have the logger to debug SQL queries and it does point to the right table )
question from:
https://stackoverflow.com/questions/65909468/invalid-column-name-column-in-ef-core-fluent-api 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…