I am using generic repository pattren in an ef 5 app.
there is a create() method in IDbSet, which in ef7's DbSet does not exists.
description of Create() Method in EF5 is as follow:
Creates a new instance of an entity for the type of this set. Note that this instance is NOT added or attached to the set. The instance returned will be a proxy if the underlying context is configured to create proxies and the entity type meets the requirements for creating a proxy.
Code sample:
public interface IRepository<T> where T : IDisposable {
T Create();
}
public class Repository<T> : IRepository<T> where T : IDisposable {
protected IUnitOfWork uow;
protected IDbSet<T> entity;
public Repository(IUnitOfWork uow) {
this.uow = uow;
this.entity = uow.Set<T>();
}
public T Create() {
return entity.Create();
}
}
my question is, why Create(); method is removed in EF7's DbSet(notice that IDbSet is also removed in EF core)
and I Found this question: Create() Versus new T(), have i any problem in future if i use new T()?