Top "Dbcontext" questions

The DbContext API first shipped with Entity Framework version 4.1 and provides a more productive surface for working with the Entity Framework and can be used with the Code First, Database First, and Model First approaches.

Entity Framework, Code First, Update "one to many" relationship with independent associations

It took me way too long to find a solution to the scenario described below. What should seemingly be a …

entity-framework associations code-first dbcontext
Entity Framework Core DbContext and Dependency Injection

I'm building a service application using Web API, .Net Core and EntityFramework Core. For configuring options in my DbContext I'm …

entity-framework dependency-injection asp.net-web-api2 dbcontext entity-framework-core
How to Moq Entity Framework SqlQuery calls

I've been able to mock DbSet's from entity framework with Moq using this link. However, I would now like to …

c# entity-framework moq dbcontext
Using Entity Framework Core 3.1 with UseInMemoryDatabase option in ServiceProvider ( Scoped lifetime )

I have migrated a web application project from .NET Core 2.1 to 3.1 (also EF Core from 2.1.1 to 3.1.0). After the migration, some …

c# unit-testing entity-framework-core dbcontext .net-core-3.1
What is the best way to instantiate and dispose DbContext in MVC?

MVC 3 + EF 4.1 I'm choosing between two approaches to deal with DbContext: Instantiate in Application_BeginRequest, put it into HttpContext.Current.…

asp.net-mvc entity-framework entity-framework-4.1 poco dbcontext
Entity Framework Code First: which DataType attribute for DateTime2?

Sometime when using Entity Framework Code First, the default conventions do not create the database type you want. For instance …

c# entity-framework dbcontext
EF 4.1 OnModelCreating not called

I have a problem with EF 4.1 not calling OnModelCreating so that I can configure tables etc. I have an existing …

c# entity-framework-4.1 dbcontext
How to configure DbContext to work with Oracle ODP.Net and EF CodeFirst?

I'm trying to work with EF CodeFirst under Oracle with ODP.net. This is my DbContext class: public class MyCEContext : …

asp.net-mvc-3 oracle ef-code-first odp.net dbcontext
How to extend DbContext with partial class and partial OnModelCreating method in EntityFramework Core

I'm using EF Core and DatabaseFirst approach. My dbContext is created automatically by Scaffold-DbContext command. I need to add some …

c# entity-framework-core dbcontext partial partial-classes
SqlException: Syntax Error Near 'GO'

I am having trouble sending a SQL statement through a DbContext using context.Database.ExecuteSqlCommand(). I am trying to execute …

sql-server-2008 dbcontext