When trying to load related data and following the guide on Explicit Loading of Related Data, I get the following error:
IApplicationDbcontext does not contain a definition for
Entry.
My example code, similar to theirs, includes:
var person = _context.Persons.Single(p => p.PersonId = id);
_context.Entry(person).Collection(p => p.Addresses).Load();
The difference in my case is that I am injecting an IApplicationDbContext which looks pretty standard and I assume doesn't make a difference:
public class ApplicationDbContext : DbContext, IApplicationDbContext
{
...
public DbSet<Person> Persons { get; set; }
public DbSet<Address> Addresses { get; set; }
...
}
I have Microsoft.EntityFrameworkCore 5.0.7 within this project.
Your IApplicationDbContext must declare the following method signiture in it in order to work.
EntityEntry<TEntity> Entry<TEntity>([NotNullAttribute] TEntity entity) where TEntity : class;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With