Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 901219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:31:19+00:00 2026-05-15T15:31:19+00:00

Entity Framework 4 – STE – simple DB with single table Blogs having BlogID

  • 0

Entity Framework 4 – STE – simple DB with single table Blogs having BlogID PK column…

var samplesDbEntities = new SamplesDBEntities();
var blogId = Guid.NewGuid();
samplesDbEntities.Blogs.AddObject(new Blog() { BlogID = blogId });
var objectSetResult = samplesDbEntities.Blogs
                                       .Where(p => p.BlogID == blogId)
                                       .SingleOrDefault();

(result of code execution => objectSetResult == null after the last line)

AFAIK, ObjectContext is implementation of UoW pattern and in which case I guess I should get the result back from ObjectSet (Repository) just “marked as transient”
Can someone explain me what I am doing wrong and why objectSetResult has null value here?

(Yes, I am aware of ObjectStateManager, but to me it is more of a patch for the upper mentioned architectural problem)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:31:20+00:00Added an answer on May 15, 2026 at 3:31 pm

    The pattern violated in your example is not Unit Of Work pattern but Identity Mapping.

    Unit of Work track changes made to objects by your code instead of you take care about that manually.

    Identity Mapping pattern enacts object context to have single entity instance for single value of primary key.

    It is strange for me but Entity Framework (as well as LINQ 2 SQL) does not map object identity in every situation, and situation described above is one of such cases.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

New to entity framework, but I would think this should be pretty simple. My
Entity Framework Code First is a great framework for developing new projects. But what
In Entity Framework (VS2010) how do I create an association to/from the same table?
Using Entity Framework. Simple Page class with tree hierarchy. public class Page { public
Entity Framework Code First will auto-create a table in the database base based on
Using Entity Framework CodeFirst, how do I create a created datetime column that gets
Background: Entity Framework 4, with SQL Server 2008 Problem: I have a table Order
In Entity Framework, is there any performance cost of doing this... var businesses =
Entity Framework magically interprets the following table structure as a many-to-many relationship. table foo
Entity framework is cripplingly slow so I tried using a stored procedure but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.