私のテーブルは次のとおりです。
create table Entities(
EntityId bigint not null identity(1, 1),
Name nvarchar(64) not null,
ParentEntityId bigint null
)
alter table Entities add constraint PK primary key (EntityId)
alter table Entities add constraint FK foreign key (ParentEntityId) references Entities(EntityId)
私のモデルは次のようになります。
public class Entity
{
[Required]
public virtual long EntityId { get; set; }
[Required]
public virtual string Name { get; set; }
public virtual long? ParentEntityId { get; set; }
public virtual Entity ParentEntity { get; set; }
}
流暢なAPIマッピングを使用してプロパティをマッピングしようとしていParentEntity
ますが、これを機能させることができませんでした。どうすればいいですか?
前もって感謝します!
編集:コードの不一致を修正しました。