How To Update EF 4 Entity In ASP.NET MVC 3?

后端 未结 6 1927
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-09 07:26

I have 2 projects - a class library containing an EDM Entity Framework model and a seperate ASP.NET MVC project.

I\'m having problems with how your suppose to edit and s

6条回答
  •  北恋
    北恋 (楼主)
    2021-02-09 07:41

    I found this tutorial on the asp.net website to be very helpful: Getting Started with EF using MVC - Updating Related Data

    The method to pay attention to is TryUpdateModel which will update the related model in the "standard" manner (setting the entity to a modified state and passing everything in) and then will let you customize how certain properties are updated.

    I ran into problems with entity keys and this helped me get past those.

提交回复
热议问题