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.

How can I log the generated SQL from DbContext.SaveChanges() in my Program?

According this thread, we can log the generated SQL via EF, but what about DbContext.SaveChanges()? Is there any easy …

c# sql entity-framework logging dbcontext
What do I need to add into OnModelCreating(DbModelBuilder modelBuilder) function to define relations between Person and Role?

I'm using EntityFramework version 5.0 in WinForms project, .net 4.5. I have created 2 for me important Entities public class Role { [Key] [DatabaseGeneratedAttribute(…

c# entity-framework entity-framework-5 dbcontext
Get Auto Identity Key after Insert via EF

Is there a straight forward way of retrieving a DB auto generated primary key when adding a record via Entity …

entity-framework entity-framework-4.1 dbcontext
The provider did not return a ProviderManifestToken string error

I am trying to create a web app using ASP.Net MVC3, Entity Framework and MySQL. I have added the …

mysql asp.net-mvc-3 entity-framework dbcontext
How to Refresh DbContext

I want to refresh all entities of my DbContext without recreating it, I tried the following and none of them …

c# entity-framework entity-framework-4 refresh dbcontext
Configure multiple database Entity Framework 6

In my solution I have 2 projects that use Entity Framework 6. Each points to a different database, both using the same …

c# entity-framework dbcontext entity-framework-6
DbContext AutoDetectChangesEnabled set to false detecting changes

I'm a bit stumped. From what I've read setting the DbContext.AutoDetectChangesEnabled to false should disable change tracking requiring one …

entity-framework entity-framework-5 dbcontext
c# entity framework: correct use of DBContext class inside your repository class

I used to implement my repository classes as you can see below public Class MyRepository { private MyDbContext _context; public MyRepository(…

c# entity-framework dbcontext
Entity Framework Core Using multiple DbContexts

I'm having a problem that when I try to access a field in my PartsDbContext I get the following error: …

c# entity-framework-core dbcontext asp.net-core-1.1
DbContext has been disposed

I developed a web application with ASP.NET MVC 4 and SQL Server 2008, I create ContextManager class to have only one …

c# asp.net asp.net-mvc entity-framework dbcontext