With Entity Framework Core (tested with Version 2.1) you can get the current context using
// DbSet<MyModel> myDbSet
var context = myDbSet.GetService<ICurrentDbContext>().Context;
How to get a DbContext from a DbSet in EntityFramework Core 2.0
More Related Contents:
- NSubstitute DbSet / IQueryable
- One DbContext per web request… why?
- Validation failed for one or more entities. See ‘EntityValidationErrors’ property for more details [duplicate]
- Entity Framework Code First – two Foreign Keys from same table
- Ignoring a class property in Entity Framework 4.1 Code First
- Entity Framework Join 3 Tables
- The entity type is not part of the model for the current context
- Why is .Contains slow? Most efficient way to get multiple entities by primary key?
- How can I log the generated SQL from DbContext.SaveChanges() in my Program? [duplicate]
- LINQ to Entities only supports casting EDM primitive or enumeration types with IEntity interface
- Why is inserting entities in EF 4.1 so slow compared to ObjectContext?
- EF Code First: How to get random rows
- The operation cannot be completed because the DbContext has been disposed using MVC 4
- Configure multiple database Entity Framework 6
- Navigation Property without Declaring Foreign Key
- Better way to query a page of data and get total count in entity framework 4.1?
- DbContext discard changes without disposing
- An error occurred while saving entities that do not expose foreign key properties for their relationships
- How to Refresh DbContext
- Entity Framework Code First Date field creation
- What is the difference between IDbSet.Add and DbEntityEntry.State = EntityState.Added?
- mapping multiple tables to a single entity class in entity framework
- Create association on non-primary key fields with Entity Framework 4.1 Fluent API
- How do I clear tracked entities in entity framework
- Entity Framework Specification Pattern Implementation
- MySQL Entity Framework Error – The specified store provider cannot be found in the configuration, or is not valid
- How to I apply filter while paginating in Asp.net MVC and entity Framework?
- Global setting for AsNoTracking()?
- System.Data.MetadataException: Unable to load the specified metadata resource
- Where to convert business model to view model?