I have n-tier application that has many layers in different assemblies.
i use entity framework 6.1 and i want to add ObjectState
property to the base entity to track entity states. The problem is BaseEntity
is located in my domain objects dll that is database independent and i want to add ObjectState
in the Entity Framework project as this property is entity framework related.How to achieve this behavior?
public enum ObjectState
{
Unchanged,
Added,
Modified,
Deleted
}
public interface IObjectState
{
[NotMapped]
ObjectState ObjectState { get; set; }
}
If you mean, that you can't implement
IObjectState
inBaseEntity
, because it must be independent from EF specific, then you should have two sets of entities - one for domain, one for EF, and use mapping (possibly, Automapper) between these sets:Actually, when using layered architecture, this is a preferable way, when each layer operates its specific models.