This project is read-only.

Help with EntityFramework and NerdDinner

Jan 1, 2011 at 2:12 AM

Hi guys,

I'm new to both MVC and EntityFrame work. I am trying to follow the NerdDinner example, but use my own project. I created an EntityFramework project, and then my MVC project, referencing the EF project. All is good. I am viewing data, and inserting data well.

But now I am looking at the NerdDinner business rule validation example.

I think I may have an out dated book, but does the 'Professional ASP.Net MVC 1.0' book make use of Entity Framework?

On Page 32, it starts with adding a partial 'Dinner' calls, which has the validation rules in it. It mentions that the partial class is partial to Dinner class generated/maintained by LINQ to SQL. Now, because I am using a separate Entity Framework project, I can't really follow this model, right? Would the MVC 2.0 book suite my requirements a bit better?

Jan 2, 2011 at 9:44 PM

You can use partial classes with Entity Framework the same as you can with LINQ to SQL.

Jan 2, 2011 at 10:28 PM

Thanks - but can this (partial classes) still be done even though the EntityFramework model is in a separate project to the MVC code?

Jan 3, 2011 at 2:00 PM

Yes. The code file (.cs) that adds the validation attributes to the partial class can be part of the project that contains the Entity Framework or it can be part of the MVC project.

Generally, I would prefer to keep it with the data layer project, however a case can be made that it belongs in the user interface (MVC) layer.