Fluent Nhibernate composed entity, specify foreign key

╄→гoц情女王★ 提交于 2019-12-11 17:52:26

问题


I have a Fluent Nhibernate map like :

 public class UserMap : ClassMap<PortalUser>
{
    public UserMap()
    {
        WithTable("aspnet_Users");
        Id(x => x.Id, "UserId")
            .GeneratedBy.Guid();
        Map(x => x.Name, "UserName");
        Map(x => x.Login, "LoweredUserName");
        WithTable("LdapUsers", m => m.Map(x => x.FullName, "FullName"));

    }
}

My foreign key column in table "LdapUser" is UserId but the select that gets generated is going to look for a "PortalUserId".
Is there a way to specify the relation key direcly?


回答1:


Try this:

...
WithTable("LdapUsers", m => {
    m.Map(x => x.FullName, "FullName");
    m.WithKeyColumn("UserId");
});


来源:https://stackoverflow.com/questions/796949/fluent-nhibernate-composed-entity-specify-foreign-key

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