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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:05:22+00:00 2026-05-24T19:05:22+00:00

I am working on some CRUD methods for a web app. I am using

  • 0

I am working on some CRUD methods for a web app. I am using Entity Framework with SQL Server 2008. In particular, I have two tables that are linked using a cross reference table. It’s in the following format:

  • Table Tbl_Plan
    • PlanId
    • PlanNm
    • Active
  • Table Tbl_Person
    • PersonId
    • PersonNm
    • PersonData
  • Xref table Xref_PersonPlan
    • PersonId
    • PersonNm

Now, when I am creating a new plan I have been trying to link the two together. I’m not sure how. I know it has something to do with referencing the relationship or creating it.

The tables are set up correctly, because I can pull the data just fine once it’s created (i.e. my sample entries in SQL Server) but creating the reference is where I am stumped. I tried the following:

using (Entities context = new Entities())
{
// TblPlan plan has already been instantiated
plan.TblPersons.Add(person);

context.AddToTblPlans(plan);

context.SaveChanges();

But obviously, the .Add() isn’t what I’m looking for….help?

  • 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-24T19:05:23+00:00Added an answer on May 24, 2026 at 7:05 pm

    Someone just pointed me in the right direction. I should have waited ten more minutes. I was missing the .AttachTo() – I needed to attach the reference to the context before adding, since it was throwing an InvalidArgumentException.

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

Sidebar

Related Questions

I'm working on some production software, using C# on the .NET framework. I really
I am working on my second CI application. I have created some simple CRUD
I'm working on a personal project using WPF with Entity Framework and Self Tracking
I've created a plugin doing some crud operations. In the web-app/images/icons folder I've got
I am using an ObservableCollection to wrap some of my generated entity framework objects.
I have been working on some legacy C++ code that uses variable length structures
I'm working on a web application framework, which uses MSSQL for data storage, mostly
I have some working JavaScript that I want to convert to pure jQuery. Please
I'm working on an app, which allows users to manage (CRUD) content stored on
I'm working with system using Linq-2-SQL as its data layer, but which uses stored

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.