What you may want to do is try putting them in the same namespace. Also you may want to comment out the check you have above.
BaseEntity is in a different namespace to the entities. What you may want to do is try putting them in the same namespace. Also you may want to comment out the check you have above: return type.
Namespace == "Domain. Model" && type. IsClass; The above statement may be what is causing you to only map your base classes.
What namespace is your base class in and what namespace are one of your example entities in? When I run into problems like this I try to simplify things until I find out what is causing my issues. Edit: After further research I think you need to use the following: .
IgnoreBase(typeof(BaseEntity)); So your code above would be changed to: private static AutoPersistenceModel CreateMappings() { return AutoMap. AssemblyOf(new AutomappingConfig()) .Conventions.Add() . IgnoreBase(typeof(BaseEntity)); } This is an excerpt taken from the FNH Wiki: We've added the IgnoreBase call which simply instructs the automapper to ignore the Entity class; you can chain this call as many times as needed.
With this change, we now get our desired mapping. Entity is ignored as far is Fluent N and all the properties (Id in our case) are treated as if they were on the specific subclasses.
Cole w sorry for the delay in replying, I have tried what you suggested but I still get the same result, a table is created for each class but only with the Id field in. – geepie Apr 27 at 21:05 @geepie take a look at my edit above and see if this helps you. I was able to duplicate what you were seeing and this fixed it for me.
– Cole W Apr 28 at 1:31 @geepie Also whenever you try to regenerate your schema I would delete the old tables from your db first. I experienced issues with this unless I deleted them first. – Cole W Apr 28 at 11:38 I agree that IgnoreBase is probably what is needed - not IncludeBase.
I can't imagine that @geepie would want his DB schema to include the inheritance relationship between BaseEntity and its subclasses. It's not helpful for every table to join to a single table that dishes out all of the id's. – Daniel Schilling Apr 28 at 18:56 @Cole W thanks for your edit, I will take it into account and try again.
– geepie Apr 271 at 12:24.
From Automapping: base-type as an inheritance strategy: Abstract base-classes You'll notice that our Entity class is abstract. This is good practice, but for the record, it is not mandatory. If you're experiencing problems, it's unlikely to be this.In case you're wondering, making the class abstract is like saying "I'll never create this directly, instead I will create derived classes such as Customer and Order (which inherit from Entity).
" The default behavior is to consider abstract classes as layer supertypes and effectively unmapped, you may want to change this for specific scenarios. The easiest way to do this is to use IncludeBase, where T is your entity.AutoMap. AssemblyOf(cfg) .IncludeBase(); AutoMap.
AssemblyOf(cfg) . IncludeBase(typeof(BaseEntity)); Article: Auto-mapping generic base classes.
Thanks for your input. How do I include my base class then as its a BaseEntity of a type, . IncludeBase>(); doesn't work – geepie Apr 18 at 13:07 Any ideas?
– geepie Apr 20 at 12:47 @geepie - See my updated code and link – rebelliard Apr 20 at 13:21 I changed my automap to include the base entity but it is still only generating the ID's in the tables. Bit stuck on this, not sure what to try? Thanks for your help so far.
– geepie Apr 20 at 23:10.
From Automapping: base-type as an inheritance strategy.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.