Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The type or namespace name 'DbEntityEntry<TEntity>' could not be found

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();
}
like image 940
A Bit of Help Avatar asked Jan 07 '23 22:01

A Bit of Help


1 Answers

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.

like image 76
poke Avatar answered Jan 23 '23 02:01

poke