Nhibernat mapping aspnet_Users table
Posted
by Michael D. Kirkpatrick
on Stack Overflow
See other posts from Stack Overflow
or by Michael D. Kirkpatrick
Published on 2010-03-31T18:26:09Z
Indexed on
2010/03/31
21:13 UTC
Read the original article
Hit count: 364
My User table I want to map to aspnet_Users:
<class name="User" table="`User`">
<id name="ID" column="ID" type="Int32" unsaved-value="0">
<generator class="native" />
</id>
<property name="UserId" column="UserId" type="Guid" not-null="true" />
<property name="FullName" column="FullName" type="String" not-null="true" />
<property name="PhoneNumber" column="PhoneNumber" type="String" not-null="false" />
</class>
My aspnet_Users table:
<class name="aspnet_Users" table="aspnet_Users">
<id name="ID" column="UserId" type="Guid" />
<property name="UserName" column="UserName" type="string" not-null="false" />
</class>
I tried adding one-to-one, one-to-many and many-to-one mappings. The closest I can get is with this error: Object of type 'System.Guid' cannot be converted to type 'System.Int32'.
How do I create a 1 way mapping from User to aspnet_User via the UserId column in User?
I am only wanting to create a reference so I can extract read-only information, affect sorts, etc. I still need to leave UserId column in User set up like it is now. Maybe a virtual reference keying off of UserId? Is this even possible with Nhibernate?
Unfortunately it acts like it only wants to use ID from User to map to aspnet_Users. Changing the table User to have it's primary key be UserId instead of ID is not an option at this point.
Any help would be greatly appreciated. Thanks in advance.
© Stack Overflow or respective owner