Question


I Want to create table (SQL Server) that contains users identity GUID and make reference to it in Fluent NHibernate, here is my model:

public class Invoice {
    public virtual Guid Identity { get; set; }
    public virtual MembershipUser User { get; set; }
    public virtual int Price { get; set; }
}

So the mapping should be:

public class InvoiceMap : ClassMap<Invoice> {
    public InvoiceMap() {
        Id(x => x.Identity).GeneratedBy.GuidNative();
        Reference(x => x.User).Column("User");
        Map(x => x.Price);
        Table("invoices");
    }
}

But there are only one problem. The class MembershipUser also should be mapped.
How I can do this without mapping MembershipUser?

Was it helpful?

Solution

I guess your question is "how to use MembershipUser/Membership and Role Provider in nHibernate".

First of all, if you don't want to reinvent the wheel, I'd suggest to remove the MembershipUser property from your class and just put a reference to some identifier. Otherwise it is getting more complex. Later you can convert/retrieve the MembershipUser from your MembershipProvider...

There is one good article on codeplex describing how to implement a custom membership provider with nHibernate http://www.codeproject.com/Articles/55174/Custom-Fluent-Nhibernate-Membership-and-Role-Provi

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top