Trying to implement DDD using ASP.NET Boilerplate and Entity Framework
Employee object
public class Employee : Entity<long>
{
public virtual string Name { get; protected set; }
public virtual Nationality Nationality { get; protected set; }
}
defines property Nationality, which is value object
public class Nationality : ValueObject<Nationality>
{
public virtual string Name { get; protected set; }
}
Attempt to add database migration produces obvious error
EntityType 'Nationality' has no key defined. Define the key for this EntityType.
Took a look at 3 different approach to persist value object in database
Should i implement one of the above mentioned method manually to persist ValueObject (if so what are some of the best practices) ? or it's already done by ASP.NET Boilerplate Framework ?
ValueObject<T>? I think the error has to do with the inheritance.Nationalityas such should be interpreted as value object (ComplexTypein EF terms).6.1.3.ValueObject<T>andEntity<T>from ABP. As a last resort, trymodelBuilder.ComplexType<Nationality>();.ComplexTypeis what i ended up doing, but it denormalized database structure,Nationality's columns intoEmployee's table.