× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Be sure to use ViewModels whenever possible

Codementor User
Sep 30, 2014
<p>For beginner MVC/Web Api users, it may seem really nice to just be able to post your data model straight into the controller and most of the time, this works. However, the more complex your object is, the bigger the chances that you'll run into a conflict such as the property ClientId is 5 but your Client object that you submitted using a framework such as Angular or Knockout says 4. <br><br>EF will look at this and freakout because it thinks your trying to do an illegal procedure. A really easy way to get around this is to manipulate your data via ViewModels or Models that only contain the properties that your users is actually going to interact with and then use the view model to update your data model.</p>
comments powered by Disqus