Mapping overrides not being picked up
Hi,
In my Fluently.Configure statement I'm using AutoMappings and I am using
.UseOverridesFrom AssemblyOf<PropertyMappingOverride>()
The PropertyMappingOverride class is defined in the same assembly as this statement and is recognized by Intellisense.
I have two overrides currently defined in two different files:
namespace QuotesApp.MappingOverrides
{
class PropertyMappingOverride : IAutoMappingOverride<Property>
{
public void Override(AutoMapping<Property> mapping)
{
mapping.HasMany<AssessedItem>(x => x.AssessedItems).Inverse().AsBag();
}
}
}
namespace QuotesApp.MappingOverrides
{
class AssessedItemMappingOverride : IAutoMappingOverride<AssessedItem>
{
public void Override(AutoMapping<AssessedItem> mapping)
{
mapping.References<Property>(x => x.Property).Not.Nullable();
mapping.Map(x => x.PropertyClassification).Length(50);
}
}
}
I have tried putting breakpoints in both of these methods, but they never get hit. I even tried throwing an exception in the overrides, but they seem to be completely ignored. I confirmed this by comparing the hbm files generated with and without the overrides. No difference. Is there something else I need to do?
Here is the complete configuration statement:
return Fluently.Configure()
.Database(persistenceConfigurer)
.Mappings(m => m.AutoMappings.Add(
model.AddEntityAssembly(typeof(EntityBase).Assembly)
.IgnoreBase<EntityBase>()
.IncludeBase<AssessedItem>()
.IncludeBase<Location>()
.Where(t => t.Namespace.EndsWith("DomainModel"))
.Conventions.Add<MyIdConvention>()
.Conventions.Add<ReferenceForeignKeyConstraintConvention>()
.Conventions.Add<HasManyForeignKeyConstraintConvention>()
.Conventions.Add(ForeignKey.EndsWith("ID"), PrimaryKey.Name.Is(x => "ID"))
.Setup(s => {s.SubclassStrategy = t => SubclassStrategy.JoinedSubclass;})
.Override<Location>(map => { map.Not.LazyLoad(); })
.Override<DlsLocation>(map => { map.IgnoreProperty(x => x.DisplayString); })
.Override<DlsLocation>(map => { map.IgnoreProperty(x => x.SortingString); })
.UseOverridesFromAssemblyOf<PropertyMappingOverride>()
).ExportTo("C:\\Temp\\hbm"))
.ExposeConfiguration(BuildSchema)
.BuildSessionFactory();
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by James Gregory on 12 Mar, 2010 11:38 PM
Your override classes need to be public.
3 Posted by MylesRip on 15 Mar, 2010 02:42 PM
Yeah, that would do it.
Thanks!
James Gregory closed this discussion on 17 Mar, 2010 10:38 AM.