none
update/insert joining table RRS feed

  • Question

  • Hi I'm developing a little solution using .NET, MVC and EF. I create my database through designer so I have edmx file. I want to update this juntion table which is auto-generated by EF designer but Don't know how to do. 

    If I have code first approach, I would use OnModelCreating(), modelBuilder.Entity<> methods to map junction table but since I have edmx file, I cannot use that.

     db.Entry(ParentEntity).State = EntityState.Modified;
     db.SaveChanges();

    above code only updates properties but navigation properties

    Anyone please explain me how to update junction table? 


    • Edited by MVCNoobking Wednesday, November 6, 2013 4:41 AM
    Wednesday, November 6, 2013 4:41 AM

Answers

  • Hello,

    >>I want to update this juntion table which is auto-generated by EF designer but Don't know how to do.

    I am confused that which model you have used? DataBase First? Model First Or Code First?

    >>above code only updates properties but navigation properties

    For updating navigation properties, we need to iterate manually on related entities. Have a look at this question and answer which might be helpful.

    http://stackoverflow.com/questions/12081683/mvc-entity-framework-modifying-child-entities/12085011#12085011

    If this does not work for, please let me know and I am appreciated that if you share the table structure and regarding codes.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 7, 2013 8:23 AM
    Moderator