I have 2 tables:
1) Parent
2) Child
In codefirst I have the following definition:
public class Parent
{
public int ParentId { get; set; }
public ICollection<Child> child { get; set; }
}
However in the db, the child table has the following foreign key defined:
ParentParentId (FK, int, NULL)
How do I ensure it just specifies ParentId in the foreign key? Do I need to explicitly set the parent key using the fluent configuration?
Yes you must either include Foreign key property in the child entity:
Or you must rename the column with fluent API: