Questions tagged [objectcontext]

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

302 questions
6
votes
1 answer

Entity framework ObjectContext share - pros and cons

In my project I use entity framework 4.0 as ORM to persist data in a SQL Server. My project is a ribbon from application with a grid view and navigation tree in the main form with ribbon panel on top of it. My app basically acts a CRUD UI with…
Narayanan
  • 3,736
  • 2
  • 19
  • 24
6
votes
1 answer

The ObjectContext instance has been disposed and can no longer be used for operations that require a connection

I'm having trouble with one of my queries because of EF's change tracking and lazy loading features. The thing is that after I'm getting the result of the query, I'm using AutoMapper to map the domain objects into my business model but it keeps…
5
votes
2 answers

How to create Entity Framework ObjectContext?

I have many DBs in one SQL server. I placed connectionString as template(look at Initial Catalog={0}) into web.config.
theateist
  • 13,879
  • 17
  • 69
  • 109
5
votes
1 answer

C# Entity Framework using only one ObjectContext per HttpContext

In ASP.NET MVC 2, using Entity Framework 4, I'm getting this error "An entity object cannot be referenced by multiple instances of IEntityChangeTracker". A search of SO shows that it is probably because I have different instances of the Entity…
JK.
  • 21,477
  • 35
  • 135
  • 214
5
votes
1 answer

Are there DbContext functions not available in ObjectContext?

Microsoft has an introduction article describing DbContext features. Some of them, like filtering related entities I hadn't seen in ObjectContext. Is that functionality really new for DbContext and not available in ObjectContext? What are the other…
Shaddix
  • 5,901
  • 8
  • 45
  • 86
5
votes
1 answer

MVC 3 - The ObjectContext instance has been disposed and can no longer be used for operations that require a connection

I'm very new to C# and MVC in general and I've been creating my own little blog site as a test project. Although most things are working up to this point, I have had problems selecting multiple columns from LINQ queries. It was only after…
John H
  • 14,422
  • 4
  • 41
  • 74
5
votes
3 answers

What's the fastest way to get an ObjectContext reference from an entity object?

I'm creating extensions for my EntityFramework objects as described in How to: Customize Generated Data Objects but in some of those extensions I need to get the instance's ObjectContext to look up some other values in the model. I've found Tip 24 –…
John Kaster
  • 2,509
  • 1
  • 33
  • 40
5
votes
4 answers

Make sure Entity framework always reads from database?

I have this applikation that is actually two applications, a webapplication and a console application. The console application is used as a scheduled task on the windows machine and is executed 3 times a day to to some recurring work. Both…
Vinblad
  • 676
  • 1
  • 7
  • 18
5
votes
3 answers

IQueryable Repository with StructureMap (IoC) - How do i Implement IDisposable?

If i have the following Repository: public IQueryable Users() { var db = new SqlDataContext(); return db.Users; } I understand that the connection is opened only when the query is fired: public class ServiceLayer { public…
RPM1984
  • 72,246
  • 58
  • 225
  • 350
5
votes
2 answers

Entity Framework Object Context in ASP.NET Session object?

We have a multi-layered Asp.NET Web Forms application. The data layer has a class called DataAccess which impements IDisposable and has an instance of our Entity Framework Object Context as a private field. The class has a number of public methods…
andrej351
  • 904
  • 3
  • 18
  • 38
5
votes
2 answers

Global Javascript Event Handling Object Context

I have the following problem in event handlers in Javascript. I've got an object that has a mousemove event handler like so: function MyObject(){ } function MyObject.prototype = { currentMousePosition: null, onMouseMove: function(ev){ …
Matt
  • 6,264
  • 10
  • 54
  • 82
5
votes
3 answers

EF6 Type of context 'System.Data.Entity.Core.Objects.ObjectContext' is not supported

I have a new project created using Visual Studio 2013 with an ADO.NET Entity Data Model (EF6). Now I have to use some Dynamic Data function (like access to MetaTable object), so I add this code: MetaModel model = new MetaModel(); …
gidanmx2
  • 469
  • 1
  • 9
  • 24
5
votes
1 answer

MVVM + Entity Framework architecture confusion

I'm using Prism framework with EF in WPF application. ViewModel: keeps service references (passed by unity container). Services: are providing "high level" operations with data keeps reference of Repository, which provides basic CRUD operations…
yurislav
  • 1,119
  • 12
  • 17
4
votes
2 answers

Managing Entity Framework ObjectContext in ASP.NET

I'm using the Entity Framework for an ASP.NET Web Forms application and I'm wondering how I should deal with ObjectContext and it's lifetime. For example, I have an InviteService class that manages invites such as creating and accepting invites. The…
Freek
  • 179
  • 1
  • 5
  • 13
4
votes
2 answers

Entity Framework Detach an entity and the related entities gone

When I use Entity Framework, I want to query out a record in a context and add it to another context with the same schema, after query out the record, I detach it from the context, but the related entities are all away, is there any way to solve…
James
  • 2,570
  • 7
  • 34
  • 57
1 2
3
20 21