Most efficiently handling Create, Update, Delete with Entity Framework Code First
问题 Note: I am using Entity Framework version 5 Inside my generic repository, I have Add , Edit and Delete methods as below: public class EntityRepository<T> : IEntityRepository<T> where T : class, IEntity, new() { readonly DbContext _entitiesContext; public EntityRepository(DbContext entitiesContext) { if (entitiesContext == null) { throw new ArgumentNullException("entitiesContext"); } _entitiesContext = entitiesContext; } //... public virtual void Add(T entity) { DbEntityEntry dbEntityEntry =