Erion
Erion

Reputation: 654

Composite keys fluent nhibernate

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");

Upvotes: 2

Views: 2545

Answers (1)

Cole W
Cole W

Reputation: 15303

You should probably use this instead:

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

Upvotes: 2

Related Questions