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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:55:42+00:00 2026-05-26T14:55:42+00:00

I have a Property table and another is Detail table. Where I am using

  • 0

I have a Property table and another is Detail table. Where I am using disconnected approach where multiple properties are added and then when we click the save button it will save changes to the database. This approach of not saving for every property added is because user can delete from the list also.

Here’s what I am doing

foreach (Property P in Results)
{
  if(P.PropertyId==0 && P.EntityState==EntityState.Added)
    Repository.Properties.AddObject(P);
}

but when I try to save the data

public void Save()
{
  Repository.SaveChanges();
}

it returns error

Unable to determine the principal end of the ‘database.FK_Details_Property’
relationship. Multiple added entities may have the same primary key.

I think its because every time I call AddObject its primary key is 0 and I don’t know what could solve this problem. Is this similar or sounds familiar to anyone who has encountered it?

Thanks in advance

  • 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-26T14:55:42+00:00Added an answer on May 26, 2026 at 2:55 pm

    1)You may want to check about a circular dependency. It may be between the two entities Save Product with detail entities or viceversa

    Check here : http://social.msdn.microsoft.com/Forums/sk/adodotnetentityframework/thread/5ba666ff-0103-4a83-b4d0-743c16a99491

    2)Be careful when you add Repository.Properties.AddObject(P); because in the code behind the P entity still has a reference to Detail table.

    Make sure the detail related entity doesn’t already save the objects that are linked to it.

    If the Detail object has 3 properties , when you save Detail you will also save the 3 properties.

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

Sidebar

Related Questions

I have given a table background image using css background-image property. The cells are
I have requirement like, suppose I have a 'property' table which has 'ListingKey' field
I have a basic property bag table that stores attributes about my primary table
I have a property on a class that happens to be a Table<T> .
I have a Data Class called MyTable, and the source property is TABLE (table
I have a table which contains house details called property. I am creating a
I have property management application consisting of tables: tenants landlords units properties vendors-contacts Basically
hi i have property named. public bool ShowLabels{get; set;} and one toolbar menu button
I have database relation as follows between question table and Hardware detail table .
I have a table that's holding metadata for entrys from another table. The metadata-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.