Here's what I'm trying to accomplish:
Some entities should be "soft deleted," so I'd like to add a field (and respective column) called "IsDeleted." I'd like this property to be accessible only to the DAL (which can be accomplished via friend assemblies). I'd also like it if the DAL could treat all of these entities the same, via an interface (IDeletable).
To accomplish both goals, I can make IDeletable an internal interface and in classes implementing this interface I can make use of explicit interfaces:
bool IDeletable.IsDeleted { get; set; }
The DAL code would probably look something like this:
public void Delete<T>(T entity)
{
var d = entity as IDeletable;
if(d != null)
//soft delete
d.IsDeleted = true;
else
//hard delete
//....
}
The problem is that EF Code First has no way of generating the columns, as far as I can tell. I've tried using expressions, but it complains when I try casting to IDeletable.
Is there a way to force EF Code First to create columns, without expressions?