Questions tagged [objectcontext]

Core class within Entity Framework. Provides the methods to retrieve, query and manipulate entities within the entity model.

302 questions
0
votes
1 answer

Convert AddToTable methods in EntityFramework to Table.Add() method

Previously I was using object context for my application. So I was using AddToTable() methods like context.AddToTable(entity); but now I am using DbContext and I have to use the Add method like context.Table.Add(entity); Now I'm having the older…
user3275493
  • 88
  • 1
  • 11
0
votes
1 answer

Strange error debugging entity framework repository methods: data persisted even after abort

I'm having a strange error debugging my ASP.NET MVC 4 project running on Entity Framework 5. I used the model first approach. I'm calling a simple update method called from an AJAX Grid when data is updated. The issue is that changes are persisted…
prmph
  • 7,616
  • 11
  • 37
  • 46
0
votes
0 answers

How do I implement IEnumerable to enumerate an ObjectSet correctly?

My main goal is to override the DeleteObject method of ObjectSet. I'm using EntityFramework 6 with an ObjectContext that I migrated from EF 4.x. EDIT: I modified the T4 template that created the ObjectContext to associate all the ObjectSets on the…
Noel
  • 600
  • 16
  • 37
0
votes
1 answer

How can i use one connection string in multi Domain Services?

How can i change this.ObjectContext.Connection in Domain Service Constructor? I use multi Datamodel and Multi Domain Service. ...
0
votes
2 answers

Dynamic Data with multiple Entity Framework models

I am using Dynamic Data with Entity framework models. If I use this with 1 EF model, then this works like a charm. But now I need to use multiple EF models in my Dynamic Data Project and I'm receiving errors during the registration process. Code: …
0
votes
0 answers

Entity Framework Importing Stored Procedure and update its tables

I'm working on a project that works with datasets, but now will be with Entity Framework(any version). My idea is to do the following Reuse stored procedures (only selects with parameters - one or more tables) To insert, delete and update will use…
0
votes
1 answer

ExecuteStoreQuery not working with DateTime setter

I'm having trouble getting ExecuteStoreQuery to work correctly with my custom class which has a DateTime member. It gets the default DateTime value (1/1/0001 12:00:00 AM) instead of what is in the database. List results =…
0
votes
1 answer

Master details batch crud with entity framework only saving single detail record

I'm building a master details page with batch editing, that is multiple details records with single master record. but only one detail record is being saved into the data base. I tried to debug & found that detail loop is executing multiple time…
0
votes
1 answer

How to replace the entity that the objectstatemanager is tracking

I am getting the "An object with the same key already exists" on an update attempt while trying to attach an entity.Lazy loading is turned on. I googled, and found no real solution to this problem. My best solution would be to replace the entry in…
user853710
  • 1,715
  • 1
  • 13
  • 27
0
votes
0 answers

ASP.NET Entity Framework - How to use compile query while using single context per request?

Following is one of my repository class. I am using single context per request. So for each subsequent call to GetSpecificationList() will create a new object context & dispose it when it will be out of scope. Now i am confuse of following…
Paul
  • 457
  • 2
  • 11
  • 26
0
votes
1 answer

Entity Framework: Providing both DbContext and ObjectContext APIs in shared assembly

I've been constructing a system that will have a central database. Multiple applications will run on top of the database. As such, instead of having to maintain multiple entity framework diagrams and setups, I put all the entity framework classes…
dark_perfect
  • 1,458
  • 1
  • 23
  • 41
0
votes
1 answer

Entity Framework : ObjectContext safety

I'm developing n-tier application that consists of 4 web applications and one windows service and I would like to have one instance of ObjectContext per http request or one per thread. The question is should I handle situations where I would have…
0
votes
1 answer

Insertion multiple records in the same objectContext

I'm having some trouble when I try to insert data using the same objectContext. My problem is, the order that the Entity read my code is not the order that I "Add" it. Example: EntityAB has EntityA's PK as a FK. 1-N…
Michel Ayres
  • 5,891
  • 10
  • 63
  • 97
0
votes
1 answer

How to tell if I use ObjectContext API or DbContext API?

I've got two projects with different database models (though the same Entity Framework Version 5.0.0). Their queries look like the following: Project 1: if (_db.Entry(customer).State == EntityState.Detached) Project 2: if (customer.EntityState ==…
SeToY
  • 5,777
  • 12
  • 54
  • 94
0
votes
0 answers

Datagridview doesn't update

I work on windows form with entity framework 5. I have a datagridview to record new sales and a save button to save changes on my entities. But before saving the entities, I create some new stock objects. I have another gridview that looks at my…
François
  • 3,164
  • 25
  • 58