I've not been able to find an answer to this question.
Say you have ClassA
:
public class ClassA {
public Guid Id { get; set; }
public IList<ClassB> { get; set; }
}
And ClassA
has nested a collection of ClassB
objects:
public class ClassB {
public Guid Id { get; set; }
public string SomeProperty { get; set;}
}
Is there any way using NHibernate to map these objects to tables, generate the schemas but NOT have a foreign key relationship created for the ClassB
table?
UPDATE
Figured the solution - when mapping by code:
Bag<ClassA>(x => x.ClassB,
collectionMapping => {
collectionMapping.Table("ClassB");
collectionMapping.Cascade(Cascade.All);
collectionMapping.Key(key => {
key.Column("ClassAId");
key.ForeignKey("none");
});
collectionMapping.Lazy(CollectionLazy.NoLazy);
},
mapping => mapping.OneToMany(x => {
x.Class(typeof(ClassB));
})
);