I\'m starting to develop with Fluent NHiberate, and I was wondering how I create a defined \'Foreign Key\' relationship in my Mapping class.
Here\'s my class. These
Here you go:
public class Song
{
public virtual int Id { get; private set; }
public virtual Artist Artist { get; set; }
public virtual string Title { get; set; }
public class SongMap : ClassMap
{
SongMap()
{
Id(c => c.Id);
References(c => c.Artist); // Yes, that's all.
Map(c => c.Title).Not.Nullable().Length(50);
}
}
}
That being said, it's easier using the Automapper configuration.