views:

35

answers:

0

Hi, All

I have two entities:

public class A : EntityWithTypedId

{ Guid UniqueIdentifier; IList<B> Children; }

public class B: EntityWithTypedId

{ A Parent;..... }

I want to make the reference using the Guid column not the primary key Id (so I will have in the B table UniqueIdentifier not A_id). I can't make it to work for the HasMany part: In the mapping for A class:

Map(x => x.UniqueIdentifier).Column("avUniqueIdentifier").Unique().Not.Nullable(); HasMany(x => x.Children) .KeyColumn("avUniqueIdentifier") .Table("Childrens");

In the mapping for B class:

References(x => x.Parent).Not.Nullable() .PropertyRef(x=>x.UniqueIdentifier) .Column("avUniqueIdentifier");

But I get the error:

15:22:55,795 ERROR [ 7] SchemaExport [(null)]- Column 'As.aId' is not the same data type as referencing column 'Bs.avUniqueIdentifier' in foreign key 'FK6B5005B1E3E18454'. Could not create constraint.

If I remove the column name setter from

References(x => x.Parent).Not.Nullable() .PropertyRef(x=>x.UniqueIdentifier);

nhibernate create 2 columns in the B table

Thanks for help