I have three mappings as follows:
public MainChapterMap()
{
// other properties
HasMany(x => x.ClientSpecific).KeyColumn("MainChapterId");
}
public MainChapterClientMap()
{
// other properties
References(x => x.MainChapter).Column("MainChapterId");
HasMany(x => x.Details).KeyColumn("MainChapterClientId");
}
public MainChapterClientDetailMap()
{
// other properties
References(x => x.MainChapterClient).Column("MainChapterClientId");
}
MainChapter
has many client-specific chapters. The client-specific chapters (MainChapterClient
) has many translations (MainChapterClientDetail
)
The dele rules should be as follow:
- When deleting a
MainChapter
- Delete the
MainChapterClient
row - Delete the
MainChapter开发者_开发问答ClientDetail
row(s)
- Delete the
- When deleting a
MainChapterClient
- Do NOT delete the
MainChapter
row - Delete the
MainChapterClientDetail
row(s)
- Do NOT delete the
- When deleting a
MainChapterClientDetail
- Do NOT delete the
MainChapter
row - Do NOT delete the
MainChapterClientDetail
row(s)
- Do NOT delete the
But I no matter what I end up getting this error:
deleted object would be re-saved by cascade (remove deleted object from associations)[Entities.MainChapterClient#39]
I'm not sure how to set up my cascades anymore. Any help are more than welcomed!
You need to remove the reference from both sides :
MainChapterClient.Details.Remove(instance);
instance.MainChapterClient = null;
精彩评论