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 8145825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:47:14+00:00 2026-06-06T13:47:14+00:00

.Net4 Entity Framework, N-Tier (so objects are detatched) I have 2 objects generated Database

  • 0

.Net4 Entity Framework, N-Tier (so objects are detatched)

I have 2 objects generated Database first such that object1 has a Navigation Property (1 – 1) to object 2.

I can successfully make changes to other properties of object 1, but when I try to change object2 I get an error.

My webpage has a drop down list of object2 names and indices.

I have tried setting the object1.object2Id property and saving it and I get a referential Key error. (I can see that this may be because the object still holds the original object2).

If however I load in the new object2 and attempt to update object1 I get the object could not be added or attached because its EntityReference has an Entity Key Property that does not match.

So I seem to be going round in circles.

So using Detached objects and Entity Framework, what is the correct way of updating a child object / foreign key?

  • 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-06-06T13:47:16+00:00Added an answer on June 6, 2026 at 1:47 pm

    Ok, Figured it out. Its a result of me working in detatched mode. If I wait until I am at the Business tier about to write the changes, and change the fk once I have re attached the object to the context it works.

    Just one of things I needed to learn I guess !

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

Sidebar

Related Questions

I have some .NET 4 entity framework objects that I get from the DB,
.NET 4 ASP.NET I have a DetailsView that is displaying an entity framework record
I have develop one simple database application build using SilverLight5.0 + Entity Framework +
I have imported a stored procedure that returns a dataset into my Entity Framework.
I have a .NET4 web application using the Entity Framework In one of my
I have an ASP.NET 4 web app that is using the Entity Framework to
Let's say I have an Entity in my Entity Framework Model that is named
I have a .NET 4 WinForms app that uses the ADO.NET Entity Framework. Some
I'm working on my first application that will use entity framework. I've got a
My application uses asp.net 4, C# and Entity Framework. My database contains a table

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.