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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:41:20+00:00 2026-05-24T11:41:20+00:00

I am trying to update 2 tables: RESTAURANT and HOURS. The tables shere the

  • 0

I am trying to update 2 tables: RESTAURANT and HOURS. The tables shere the REST_ID key. I get an error on the line with the arrow (==>): Sorry, I’m trying to teach myself this stuff and it’s the first time I’ve tried a multi-table insert.

The object could not be added or attached because its EntityReference
has an EntityKey property value that does not match the EntityKey for
this object.

   RESTAURANT addRest = new RESTAURANT();
        addRest.REST_NAME = r_name;
        addRest.REST_STREET1 = r_street;
        addRest.CITY_ID = c_id;
        addRest.REST_PHONE = r_phone;
        addRest.REST_WEBSITE = r_web;
        addRest.HOUR = new HOUR();
        addRest.HOUR.HOURS_SUN = h_su;
        addRest.HOUR.HOURS_MON = h_mo;
        addRest.HOUR.HOURS_TUE = h_tu;
        addRest.HOUR.HOURS_WED = h_we;
        addRest.HOUR.HOURS_THU = h_th;
        addRest.HOUR.HOURS_FRI = h_fr;
        addRest.HOUR.HOURS_SAT = h_sa;
        addRest.HOURReference.EntityKey = new EntityKey("FVTCEntities.HOURS", "HOURS", 1);
        ==> db.AddToRESTAURANTs(addRest);
        db.SaveChanges();
  • 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-24T11:41:22+00:00Added an answer on May 24, 2026 at 11:41 am

    That isn’t LINQ to SQL. It’s Entity Framework.

    You don’t need to set the EntityKey, usually. Just set the HOUR properties like any POCO type. Ignore EntityKey unless you have a very specific reason to set it.

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

Sidebar

Related Questions

I'm trying to update a table in my DynamoDB tables using the PHP SDK.
I am trying to use a PHP form (new.php) to update 2 MySQL tables
hi i'm trying to update two different tables with one trigger but i keep
I'm trying to update a field in 2 tables with the same value -
TABLES: student(name,points) playsin(name->student(name), score) I'm trying to use: UPDATE STUDENT SET points = points
I'm trying to update a field in one of our relational tables. The table
I'm trying to update a single element in one of my tables using a
I would like to update multiple tables in one SQL statement. I am trying
I'm trying to update tables in my wordpress mu database. I want to update
Im trying to write a procedure to update two tables but im a little

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.