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.

DbSet.Find method ridiculously slow compared to .SingleOrDefault on ID

I have the following code (Database is SQL Server Compact 4.0): Dim competitor=context.Competitors.Find(id) When I profile this …

entity-framework ef-code-first dbcontext sql-server-ce-4 dbset
Multithreading Entity Framework: The connection was not closed. The connection's current state is connecting

So I have a windows service process that performs a workflow process. The back end uses Repository and UnitofWork Pattern …

multithreading entity-framework dbcontext
What is the best practice in EF Core for using parallel async calls with an Injected DbContext?

I have a .NET Core 1.1 API with EF Core 1.1 and using Microsoft's vanilla setup of using Dependency Injection to provide …

entity-framework asynchronous dbcontext asp.net-core-webapi
How do you configure the DbContext when creating Migrations in Entity Framework Core?

Is there way that dependency injection can be configured/bootstrapped when using Entity Framework's migration commands? Entity Framework Core supports …

c# dependency-injection .net-core entity-framework-core dbcontext
How do I foreach through my dbcontext entities in EF 4.1?

I'm using ASP.NET Entity Framework 4.1 MVC 3 (C#) I want to foreach through all the entities in my DbContext. I …

entity-framework asp.net-mvc-3 objectcontext objectstatemanager dbcontext
Using Entity Framework 6 with Multiple DB Schemas but using One DBContext

I have an application using EF as ORM. The database used to have one schema, dbo and everything was working …

entity-framework dbcontext db-schema
Why re-initiate the DbContext when using the Entity Framework?

I don't know if there is a better way to use the DbContext because it is not recommended to set …

c# .net wcf entity-framework-4 dbcontext
One transaction with multiple dbcontexts

I am using transactions in my unit tests to roll back changes. The unit test uses a dbcontext, and the …

c# .net dbcontext transactionscope
ExecuteStoreQuery with Dbcontext

I want to use ExecuteStoreQuery function of Entity Framework and I was wondered that my context variable didn't have ExecuteStoreQuery …

c# linq entity-framework objectcontext dbcontext
DbSet.FirstOrDefault()?

I'm trying to do this but it says I can't use FirstOrDefault, public static int GetId(this Context db, Type …

c# entity-framework entity-framework-4.1 dbcontext