尝试使用 ASP.NET 样板和实体框架实现 DDD
Employee
目的
public class Employee : Entity<long>
{
public virtual string Name { get; protected set; }
public virtual Nationality Nationality { get; protected set; }
}
定义属性Nationality
,它是值对象
public class Nationality : ValueObject<Nationality>
{
public virtual string Name { get; protected set; }
}
尝试添加数据库迁移会产生明显的错误
EntityType 'Nationality' has no key defined. Define the key for this EntityType.
我是否应该手动实施上述方法之一来坚持ValueObject
(如果是的话,有哪些最佳实践)?还是已经由 ASP.NET Boilerplate Framework 完成?