I have implemented a database soft delete (a boolean flag that marks entries as deleted) using the following tutorial: http://www.codeguru.com/csharp/csharp/soft-deleting-en
Well, you code seems fine to me. Perhaps there is a little mistake that is breaking your app. You could try this:
Remove the SoftDeleteAttribute
from BC_Instance
Edit the OnModelCreating
method
AttributeToTableAnnotationConvention conv =
new AttributeToTableAnnotationConvention(
"SoftDeleteColumnName",
(type, attributes) => attributes.Single().ColumnName);
modelBuilder.Conventions.Add(conv);
//this will dynamically add the attribute to all models
modelBuilder.Types().Configure(delegate(ConventionTypeConfiguration i)
{
i.HasTableAnnotation("SoftDeleteColumnName", Entity.G etSoftDeleteColumnName());
});
Delete ApplicationDbConfiguration
class
Edit the context's constructor
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
DbInterception.Add(new SoftDeleteInterceptor());
}
Hope this helps!