I am trying to use components in fluent nhibernate and am getting the below error.
FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
Does the code below look right or am I missing something?
Below is the object im ttrying to reuse
public class Thickness
{
public string Name { get; set; }
public byte ThicknessSize { get; set; }
}
I have implemented it in my entity class as below
public class Liner
{
public virtual int Id { get; set; }
public virtual Thickness Thickness { get; set; }
}
The map for the entity is
public class LinerMap : ClassMap<Liner>
{
public LinerMap()
{
Table("Liner");
Id(l => l.Id);
Component(l => l.Thickness);
}
}
The configuration looks like below
public static ISessionFactory CreateSessionFactory()
{
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(c => c
.Server("XXXXX")
.Database("XXXXX")
.Username("XXXXXXXXXX")
.TrustedConnection()))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Liner>())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Thickness>())
.BuildSessionFactory();
}
I've noticed that the fluent wiki says that this feature doesn't work for automapping hence ive explicitly used the .mapping method, but im not sure if this is enough
Any ideas will be gratefully welcome
GB
Did a little digging into the Component method and if your code is attempting to use its capabilities then it needs another parameter. I'm not sure why it would even compile the way it is written but it needs two parameters, a parameter for the reference property and another describing the the mapping for that reference property.