I am trying to clean up my code a bit and attempted to break out the mapping code for each entity into it's own file, accessible via a static method Map(). These are all in the same assembly, project, namespace, and even folder. I am however, running into some issues ...
Here's an example of one on my mapping classes ...
public
class
ModelBaseMap
{
public
static
MappingConfiguration<ModelBase> Map()
{
//
// We need to map the ModelBase as well using Horizontal Inheritance
MappingConfiguration<ModelBase> map =
new
MappingConfiguration<ModelBase>();
map.MapType().Inheritance(Telerik.OpenAccess.InheritanceStrategy.Horizontal);
return
map;
}
}
And here is the metadatsource file ...
public
partial
class
DbContextMetadataSource : FluentMetadataSource
{
protected
override
IList<MappingConfiguration> PrepareMapping()
{
List<MappingConfiguration> configurations =
new
List<MappingConfiguration>();
MappingConfiguration<ModelBase> modelBaseMap = ModelBaseMap.Map();
MappingConfiguration<DeliverableType> typeMap = DeliverableTypeMap.Map();
MappingConfiguration<Deliverable> delMap = DeliverableMap.Map();
MappingConfiguration<DeliverablePackage> pkgMap = DeliverablePackageMap.Map();
MappingConfiguration<DeliverablePackageItem> itemMap = DeliverablePackageItemMap.Map();
configurations.Add(modelBaseMap);
configurations.Add(typeMap);
configurations.Add(delMap);
configurations.Add(pkgMap);
configurations.Add(itemMap);
return
configurations;
}
}
I am getting the following error ...
Telerik.OpenAccess.Exceptions.ConfigurationException: Found configurations for property 'CreatedDate' of class 'InnovativeFoto.BLL.Models.ModelBase' both in the PrepareMapping method of the FluentMetadataContext and in the class static method returning MappingConfiguration
Is this not allowed? MUST the mapping all exist in the actual MetaDataSource file?