Entity Framework Update Entity along with child entities (add/update as necessary)

后端 未结 3 1479
一个人的身影
一个人的身影 2021-02-02 15:24

I have a many-to-many relationship between Issues and Scopes in my EF Context. In ASP.NET MVC, I bring up an Edit form that allows the user to edit a

3条回答
  •  礼貌的吻别
    2021-02-02 16:25

    **Disclaimer: I am relatively new to EF, take my answer with a bucket of salt.

    If this is an edit form, I think your issue object should not be a "new" issue, it should pull the issue out of the data store. As far as I can see by doing:

    Issue issue = new Issue { IssueID = id, TSColumn = formIssue.TSColumn }; edmx.Issues.Attach(issue); you are effectively creating a New Issue with the Id of the one you are trying to edit.

    Again, I am here looking for ways to make sense of EF myself. Sometimes I miss my SQL statements.

提交回复
热议问题