I have a model like this:
public class Entity
{
[Key, Required]
public virtual long EntityId { get; set; }
[Required]
public virtual string Name { get; set; }
public virtual long? ParentEntityId { get; set; }
}
and this is my table:
create table Entities(
EntityId bigint not null identity(1, 1),
Name nvarchar(64) not null,
ParentEntityId bigint null
)
ParentEntityId is a foreign key to EntityId.
When I try to create a Entity entity this is the exception I get:
Invalid column name 'ParentEntity_EntityId'.
I don't know why EF is picking that convention for that particular column, but if I do this:
[Column("TryPickThisName")]
public virtual int? ParentEntityId { get; set; }
The same error shows up with "TryPickThisName" column name. And finally if I write the column name correctly or remove the attribute it will show the original error message.
