Questions tagged [objectcontext]

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

302 questions
10
votes
1 answer

Is it always better to use 'DbContext' instead of 'ObjectContext'?

I just downloaded EntityFramework.dll v4.3. I've found a number of questions that compare DbContext vs. ObjectContext. But most of these are from 2010, or early 2011. I'd like to read more on the subject. Specifically, are there any books on…
bevacqua
  • 47,502
  • 56
  • 171
  • 285
9
votes
3 answers

Entity Framework 4.1 - Refresh is not a member of Context

I'm trying to revert Context changes using the Context.Refresh method but It seems like Refresh is not a member of Context. I'm using the Microsoft ADO.NET Entity Framework 4.1 RC version. Any idea?
tebi
  • 91
  • 1
  • 2
9
votes
3 answers

C# Entity Framework 4 Navigation properties causing slow performance on commit

I apologize for the lack of detail in this question - the first thing I need help on is knowing where to look to find more detail. I have a problem with enity framework 4 navigation properties apparently causing poor performance when committing…
JK.
  • 21,477
  • 35
  • 135
  • 214
9
votes
1 answer

3 methods for adding a "Product" through Entity Framework. What's the difference?

Reading this MSDN article titled "Working with ObjectSet (Entity Framework)" It shows two examples on how to add a Product.. one for 3.5 and another for 4.0. http://msdn.microsoft.com/en-us/library/ee473442.aspx Through my lack of knowledge I am…
4imble
  • 13,979
  • 15
  • 70
  • 125
9
votes
1 answer

Compiled Query no implicit reference conversion to ObjectContext

I'm creating a delegate to retrieve all album records in the database. I've used this same way in another project, but for some reason I'm getting an error this time. Have I missed a step? I'm not sure why this error is appearing. Code …
Cody
  • 8,686
  • 18
  • 71
  • 126
9
votes
2 answers

Entity framework remove object from context, but not from database

I am working on a batch process which dumps ~800,000 records from a slow legacy database (1.4-2ms per record fetch time...it adds up) into MySQL which can perform a little faster. To optimize this, I have been loading all of the MySQL records into…
8
votes
1 answer

Why is this throwing a NULL value exception?

For some reason I am getting the following error at the db.SaveChanges(); instruction: Cannot insert the value NULL into column 'UserId', table 'XXXXXXXXX_Dev.dbo.Portfolios'; column does not allow nulls. INSERT fails. The statement has been…
Stephen__T
  • 2,004
  • 3
  • 25
  • 48
8
votes
1 answer

How to add entity-framework to console application (images are included)

I try to add entity-framework to console application: I press "add new item" and then then then I added code: class Program { static void Main(string[] args) { try { …
Paul T.
  • 4,938
  • 7
  • 45
  • 93
7
votes
1 answer

How to bind EF Code First DbContext to an Asp.Net DataSource?

I've created the following Context to be used with Entity Framework Code First: public class Context : DbContext { public DbSet Animals { get; set; } } Now I would like to use this Context in an Asp.Net application to…
Kees C. Bakker
  • 32,294
  • 27
  • 115
  • 203
7
votes
4 answers

EF4 - possible to mock ObjectContext for unit testing?

Can it be done without using TypeMock Islolator? I've found a few suggestions online such as passing in a metadata only connection string, however nothing I've come across besides TypeMock seems to truly allow for a mock ObjectContext that can be…
Steve Macdonald
  • 1,745
  • 2
  • 20
  • 34
6
votes
2 answers

EntityFramework 4, DbSet and ObjectContext

few days ago i read tutorial about GenericRepository and Unit Of Work patterns http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application. I use web forms…
geek
  • 596
  • 8
  • 26
6
votes
1 answer

Using Both ObjectContext and DbContext

Scenario: Trying to extract and rearange information from one database to an other. DB A has some data I want to get. I want to store it on DB B in a slightly different structure. DB A I get using an EDMX database generated model so it uses a…
boyke
  • 103
  • 1
  • 5
6
votes
2 answers

C#/EF and the Repository Pattern: Where to put the ObjectContext in a solution with multiple repositories?

I have multiple repositories in my application. Where should I put the ObjectContext? Right now, I have a reference like ObjectContext ctx; in every repository. What is the smartest and safest way to go about this?
6
votes
1 answer

NULL handling in dbcontext and objectcontext

I have this simple LINQ query from e in Employees where e.DesignationID !=558 select e Here DesignationID is a nullable field: In objectcontext the query is translated to: SELECT [Extent1].[EmployeeID] AS [EmployeeID], [Extent1].[EmployeeCode]…
Tassadaque
  • 8,129
  • 13
  • 57
  • 89
6
votes
2 answers

Entity framework - objectcontext disposed exception

I've been debugging this program without any result, and unfortunately I can't see the root of the problem. I get this exception: The ObjectContext instance has been disposed and can no longer be used for operations that require a connection. There…
Mitulát báti
  • 2,086
  • 5
  • 23
  • 37
1
2
3
20 21