It seems that many people, including me, do not find a complete solution to add all the assemblies dumped to the bin folder if they are anonymous. In any case, I did it this way, it is not optimal, but its solution ..
Read more about NoEntity here.
private static Conf CreateConfig()
{
return Fluently.Configure()
.Database(DatabaseConfig)
.Mappings(AddAssemblies)
.ExposeConfiguration(ValidateSchema)
.ExposeConfiguration(BuildSchema)
.BuildConfiguration();
}
private static void AddAssemblies(MappingConfiguration fmc)
{
(from a in AppDomain.CurrentDomain.GetAssemblies()
select a
into assemblies
select assemblies)
.ToList()
.ForEach(a =>
{
fmc.AutoMappings.Add(AutoMap.Assembly(a)
.OverrideAll(p =>
{
p.SkipProperty(typeof(NoEntity));
})
.Where(IsEntity));
}
);
}
private static bool IsEntity(Type t)
{
return typeof(IEntity).IsAssignableFrom(t);
}
public class User : IEntity{}
public class UserMap : Entity<User>{}