Composite keys fluent nhibernate

故事扮演 提交于 2019-12-11 11:45:52

问题


Can one do this on a fluent nhibernate ?

When I try to save, I am profiding the profile and the scenario objects and the id's are not null.

Nhibernate complains that it can't insurt NULL for ProfileID column. Fluent Nhibernate doesn't know how to get to the Profile.ID ?

CompositeId().KeyProperty(x => x.Profile.ID, "ProfileID").KeyProperty(x => x.Scenario.ID, "ScenarioID");

回答1:


You should probably use this instead:

CompositeId()
    .KeyReference(x => x.Profile, "ProfileID")
    .KeyReference(x => x.Scenario, "ScenarioID");


来源:https://stackoverflow.com/questions/5709141/composite-keys-fluent-nhibernate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!