The type or namespace name 'DbEntityEntry' could not be found

c# entity-framework-core

Question

I have the following interface that I used before EF7. When I try to build the application using EF7, I receive the following error, and I cannot seem to find this type anywhere. I'd really appreciate your suggestions about how to change this code for EF7.

Error CS0246 The type or namespace name 'DbEntityEntry' could not be found (are you missing a using directive or an assembly reference?)

public interface IContext
{
    DbSet<Client> Clients { get; set; }
    DbSet<TEntity> Set<TEntity>() where TEntity : class;

    DbEntityEntry<TEntity> Entry<TEntity>(TEntity entity) where TEntity : class;

    int SaveChanges();
}
1
3
12/30/2015 5:39:39 PM

Accepted Answer

There is no DbEntityEntry type within Entity Framework 7. The whole underlying change tracking implementation has changed and there is no exact replication of this.

There is a EntityEntry type within the new Microsoft.Data.Entity.ChangeTracking namespace which has a similar purpose but it works a bit differently as is not compatible to the DbEntityEntry type in earlier versions of Entity Framework.

You can access it from the ChangeTracker which is accessible via DbContext.ChangeTracker.

But as for keeping that interface, this is unlikely to help you as quite a few things has changed.

6
12/30/2015 5:48:35 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow