zzz projects Entity Framework 6 EF 6
Home EF Core Articles Knowledge Base Online Examples
  • Home
  • EF Core
  • Articles
  • Knowledge Base
  • Online Examples

Entity Framework 6 - Knowledge Base (KB)

123 results in tag: dbcontext

How can I use DbContext and SetInitializer to correct the datetime2 out-of-range conversion error?

I'm using the DbContext and Code First APIs introduced with Entity Framework 4.1....The ...data model... uses basic data types such as ...string... and ...DateTime.... The only data annotation I'm using in some cases is ...[Required]..., but that's not on...
.net c# dbcontext ef-code-first entity-framework
asked by Alex Angas

In EF 4.1, how can I foreach through my dbcontext entities?

I'm using ASP.NET Entity Framework 4.1 MVC 3 (C#)...I want to foreach through all the entities in my DbContext. I need to be able to dynamically refer to my entities in order to make dynamic views....I have read Lerman's book, two MVC (2 & 3) books, msdn,...
asp.net-mvc-3 dbcontext entity-framework objectcontext objectstatemanager
asked by Benjamin

Update "one to many" relationships with separate associations using Entity Framework, Code First.

It took me way too long to find a solution to the scenario described below. What should seemingly be a simple affair proved to be rather difficult. The question is: ...Using Entity Framework 4.1 (Code First approach) and "Independent associations" how do ...
associations code-first dbcontext entity-framework
asked by Martin

How to use a custom DbContext to implement a Repository in Entity Framework?

We are starting to develop a small framework in our company, to share code between different applications. For data access we are using EF4. We have a custom DbContext class and a generic Repository:...public class RMDbContext : DbContext { // .... } ...
c# dbcontext entity-framework repository
asked by Rui Jarimba

SaveChanges() in DbContext - Detecting updated entities

I have overridden the SaveChanges() method in the Entity Framework 4.1 DbContext class....My override looks like this:...public override int SaveChanges() { IEnumerable<DbEntityEntry> modifiedEntityEntries = ChangeTracker.Entries().Where( e => e.Stat...
c# dbcontext entity-framework savechanges
asked by FantasticJamieBurns

Create a table dynamically in DbContext using C# EF 4.1.

I want to add tables to a SQLCe database at runtime, since the tablenames are not static and known at compile time. I try to do this with Entity Framework 4.1 and DbContext as follows:...public class PersonContext : DbContext { public PersonContext() ...
c# dbcontext entity-framework
asked by Juergen

Dbcontext executes StoreQuery

I want to use ...ExecuteStoreQuery... function of Entity Framework and I was wondered that my context variable didn't have ...ExecuteStoreQuery... method....So, I discovered that it's a method of ...ObjectContext... class, but I've already used ...DbConte...
c# dbcontext entity-framework linq objectcontext
asked by Chuck Norris

When mapping database tables using ADO.NET Entity datamodel, why does Entity Framework utilize the ObjectContext instead of the DbContext?

I am following the database approach first; I have created the tables in my SQL Server 2008 database, then I map those tables to Entity Framework classes using an ADO.NET Entity Data Model. But when I opened the designer.cs file I found the following code...
asp.net asp.net-mvc-3 dbcontext entity-framework objectcontext
asked by john Gu

Entity Framework's ObjectContext vs. DbContext

I'm using the ...DbContext... class within code that I am creating that is based on the Generic Repositories and Unit of Work design patterns. (I am following the guidance ...here....) While working on this project I have encountered the ...ObjectContext....
.net dbcontext entity-framework objectcontext
asked by afr0

"The ObjectStateManager cannot monitor multiple objects with the same key," says Entity Framework Code-First.

I'm running into an issue with Entity Framework code-first in MVC3. I'm hitting this exception:...An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key....This is a...
asp.net-mvc-3 code-first dbcontext entity-framework repository
asked by Josh

When adding and removing records, DbContext is very sluggish.

When using DbContext in a database-first scenario I found out that adding and deleting entities is very slow compared to ObjectContext. If adding 2000 entities and saving the changes at the end, DbContext is 3 to 5 times slower than ObjectContext (btw.: I...
dbcontext entity-framework
asked by Jürgen Bayer

A ProviderManifestToken string error was not returned by the provider.

I am trying to create a web app using ASP.Net MVC3, Entity Framework and MySQL....I have added the following code to my Web.Config file....<connectionStrings> <add name="ContactContext" connectionString="server=localhost;database=contacts;uid=root;pwd...
asp.net-mvc-3 dbcontext entity-framework mysql
asked by har

Why is there just one DbContext every web request?

I have been reading a lot of articles explaining how to set up Entity Framework's ...DbContext... so that only one is created and used per HTTP web request using various DI frameworks....Why is this a good idea in the first place? What advantages do you g...
asp.net c# dbcontext dependency-injection entity-framework
asked by Andrew

Entity Framework DbContext Connection string not seen in app.config/web.config

So, I have followed this instruction from ADO.NET team blog to try to make a small test project. I have double-checked everything. It doesn't seem to work and keeps saying connection string is missing....http://blogs.msdn.com/b/adonet/archive/2011/03/15/e...
database-first dbcontext ef-code-first entity-framework
asked by Tom

dbcontext loading related entities using select(), include() and where() not working

I have the following relationship between the entities. Company 1 ---* Appointments *---1 Employee...I have the .net asp membership in a separate database. Whenever a user is created it can be assigned to companies, employees, or administrators roles....i...
dbcontext entity-framework linq-to-entities
asked by Thupten

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 the Find method takes 300+ms to retrieve the competitor from a table of just 60 records....When I change the code to:...Di...
dbcontext dbset ef-code-first entity-framework sql-server-ce-4
asked by Dabblernl

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 and Unity on top of Entity Framework with the entities class generated from the edmx. I won't go into a whole lot of detail as its no...
dbcontext entity-framework multithreading
asked by Brandon

Why is EF code first throwing model backing context exception? Using 4.0.3

Heres the exception:...The model backing the 'ScannerContext' context has changed since the database was created. Consider using Code First Migrations to update the database (...http://go.microsoft.com/fwlink/?LinkId=238269...)....I get this every...
code-first dbcontext entity entity-framework mapping
asked by jwrightmail

Manage the lifetime of dbContext

I would like to tie the lifetime of a dbContext to the lifetime of a session, to - for example - be able to commit or abandon changes on a group of mutations on the dbcontext over multiple requests....Are there any other (better?) ways to accomplish this?...
asp.net-mvc-4 dbcontext entity-framework
asked by Martijn

How do I stop Entity Framework from generating BOTH ObjectContext and dbContext

Background...Visual Studio 2012...NEW Model.EDMX file created in VS2012...Copied some of the EDMX xml from a previously created EDMX into the new one...Problem / Question...Now. The EDMX (TT transform, custom tool, whatever, etc.) is generating BOTH DbCo...
dbcontext entity-framework objectcontext
asked by Jay Stevens

Page 1 of 7
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • »

Prime Library

Performance

  • Entity Framework Extensions
  • Entity Framework Classic
  • Bulk Operations
  • Dapper Plus

Expression Evaluator

  • C# Eval Expression
  • SQL Eval Function
More Projects...

Related

  • EF Extensions Online Benchmark
  • WIN an EF Extensions license
  • EF6 BatchSaveChanges for only $79
Save your entities 20× faster with EF Extensions
SaveChanges vs BulkSaveChanges

EF Extensions
Try for free now
Get monthly updates by subscribing to our newsletter!
SUBSCRIBE!