Create generic abstract class using EF database first approach
问题 I have some similar entities and I want to create a generic abstract class for CRUD operations for them, but I don't know how can access to entities in generic class. For example: public abstract class HeaderRepository<T> { public HeaderRepository() { } public virtual byte[] Insert(T item) { using (MyEntities context = new MyEntities()) { context.***** <-- What I should write to add an object to entity T } } } I hope I've got it. 回答1: You need to set your DB set. It would be better to have a