I am just starting to investigate ASP.NET MVC, and I am using the latest beta (ie. 4). I'm after the correct approach to what is a fairly CRUD scenario. My main table (Task) looks something like this -
TaskID (int) EmployeeID (int) ProjectID (int) DeptID (int) Comment (varchar) Date (datetime) Hours (float)
TaskID is the primary key. The other three IDs are all foreign keys into reference tables.
Following various tutorials, I created an object model (.edmx) using Entity Framework. I then autogenerated the controller using "Add... Controller" and selecting the "Controller with read/write..." template.
All worked well. However, obviously I want the three foreign key columns to display lookup values from the reference tables, rather than the ID. I'm really not sure what the "best practice" method for achieving this is. A few options occur to me -
- Create a view in SQL Server
- Create a view in EF (not sure how this is done)
- Look up the reference values on the fly using LINQ in the controllers
Perhaps there are other ways. I would like to hear from experienced MVC progs regarding "best practice" in this scenario.