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

  • SEARCH
  • Home
  • 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 391477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:03:55+00:00 2026-05-12T16:03:55+00:00

Here is the scenario: VS 2008 .NET 3.5 SP1 LINQ to SQL I have

  • 0

Here is the scenario:

  • VS 2008 .NET
  • 3.5 SP1
  • LINQ to SQL

I have a Product Entity, which has an ImageID field, so it has a relationship with the Image Entity. This is all defined in the schema and DBML.

Now, say I create a new Product entity, without a ImageID, and save it to the DB. At this point, the _Image field of the Entity has HasLoadedOrAssignedValue set to false, as it should.

Now, when I go and retrieve that entity from the DB, without an ImageID, i.e ImageID is set to null, and the Image Entity attached to it is also set to null, HasLoadedOrAssignedValue is set to true. Why?

Now, when I try and set the ImageID property to a valid int, I get a ForeignKeyReferenceAlreadyHasValueException exception.

Now, I know that people say, "oh, you have to set the relationship property itself, so, Product.Image = someImage, not Product.ImageID = 2", but I always set the ID field, and it always works… Well, almost always.

So, my question is twofold:

  1. Why is the HasLoadedOrAssignedValue set to true when it shouldn’t?
  2. More importantly, why am I experiencing this incoherent behavior. I know that you don’t always have to set the entity property directly, so why is it not working this time? And if this is a LINQ to SQL rule, then why can the rule sometimes be broken?
  • 1 1 Answer
  • 1 View
  • 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-12T16:03:55+00:00Added an answer on May 12, 2026 at 4:03 pm

    The problem is something is looking at the Image property and causing it to load – perhaps even the debugger.

    Set a breakpoint in the Product.Image property and see what path is causing it.

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

Sidebar

Related Questions

Here is my scenario on SQL Server 2008 R2 : This is my first
I am facing a scenario here. I have a main class which initializes a
Here's the scenario: Platform: Windows IDE: Microsoft Visual Studio 2008 Language: C# .NET framework:
In SQL Server 2008, I have a scenario where I have a table with
I'm using SQL Server 2008. I have an interesting scenario where a stored procedure
MSSQL 2008 Maybe i'm just looking in the wrong place. Here's the scenario: We
Tackling a strange scenario here. We use a proprietary workstation management application which uses
Here's my scenario - I have an SSIS job that depends on another prior
Here is the scenario that I have. I have a cvs repository in one
Here's the scenario: You have a Windows server that users remotely connect to via

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.