All Posts assertfail

View the Blog on GitHub wallymathieu

Modelbinding a complex entity framework/Linq to Sql model to mvc

14 Mar 2009

For a couple of days now I’ve been trying to “ModelBind” a more complex model (based on the Entity framework) to a controller action. The problems I’ve been having are mostly related to the amount of code for this task. I’m therefore thinking of ways to reduce the complexity. The main problem is that it’s not directly possible to bind to ordinary EF/LS-graphs.

I’ve written a small mvc application with a simple (complex model). I’ve a main entity Smurf. The Smurf entity has several SmurfChild records related to it:

smurf model

The model binding I’m trying to do is the following:

public ActionResult EditAll_CustomBinder(
        IList<smurf> smurfs

I’m editing a list of smurfs and the related smurf children in the view.


  • asp.net_mvc
  • c#
  • Entity_Framework
  • Linq_to_Sql
  • Comments or errors? Fork post and do a pull request on github