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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:32:08+00:00 2026-05-30T20:32:08+00:00

in http://msdn.microsoft.com/en-us/library/dd742359.aspx described about relationship Many-to-Many data relationships. now how can perform insert,delete,update on

  • 0

in http://msdn.microsoft.com/en-us/library/dd742359.aspx described about relationship Many-to-Many data relationships.

now how can perform insert,delete,update on CourseInstructo؟

for one-to-man relation This way I do:

var  context= new Modle2();
var course= new Course() {title="math",...};
context.Course.addObject(course);
context.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-30T20:32:10+00:00Added an answer on May 30, 2026 at 8:32 pm

    You can use navigation property at either end to manipulate the many-to-many relation.
    For example,

    using (var context = new Model2())
    {
        int courseID = 4022;
        var course = (from c in context.Courses
                     where c.CourseID == courseID
                     select c).First();
    
        int personID = 17;
        var instructor = (from p in context.Person
                      where p.PersonID == personID
                      select p).First();
    
        course.Person.Add(instructor);
        // alternatively, this will also do - instructor.Course.Add(course);
        context.SaveChanges();
    }
    

    For removing, use similar logic – for example,

    using (var context = new Model2())
    {
        int courseID = 4022;
        var course = (from c in context.Courses
                     where c.CourseID == courseID
                     select c).First();
    
        int personID = 17;
        var instructor = (from p in context.Person
                      where p.PersonID == personID
                      select p).First();
    
        course.Person.Remove(instructor);
        context.SaveChanges();
    }
    

    Update does not make sense for many-to-many relations – it essentially Add and Remove combination.

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

Sidebar

Related Questions

According to MSDN ( http://msdn.microsoft.com/en-us/library/system.windows.forms.label.autosize.aspx ), there's a note about Label 's AutoSize property:
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparametercollection.addwithvalue.aspx I'm used to adding sql parameters to a sqlCommand using the add() function.
This link http://msdn.microsoft.com/en-us/library/aa772153(VS.85).aspx says: You can register up to five notification requests on a
Please look at : http://msdn.microsoft.com/en-us/library/34yytbws.aspx In there, I read : Value types can have
The LogonUser function http://msdn.microsoft.com/en-us/library/aa378184(VS.85).aspx returns a handle that you can use to impersonate the
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawrectangle.aspx FillRectangle, DrawRectangle, FillElipse and DrawEllipse all can take 4 Float (or Single) parameters:
The MSDN documentation (http://msdn.microsoft.com/en-us/library/bb174425%28v=vs.85%29.aspx) says that Direct3D 9 applications can expect messages to be
In http://msdn.microsoft.com/en-us/library/system.security.cryptography.pkcs(VS.85).aspx we can see that the following digital signature attributes are defined: Pkcs9ContentType
According to the docs: http://msdn.microsoft.com/en-us/library/x13ttww7.aspx : The volatile keyword can be applied to reference
Quote from: http://msdn.microsoft.com/en-us/library/aa645739(VS.71).aspx "Invoking an event can only be done from within the class

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.