The ASP.NET MVC tutorials at http://www.asp.net/learn/mvc/ are an excellent resource to learning Microsoft’s MVC implementation for .NET.   In particular, there are a number of tutorials focussed on creating a Contact Manager ASP.NET MVC Application which are a great walkthrough of the MVC structure.  The C# tutorials start at http://www.asp.net/learn/mvc/tutorial-26-cs.aspx.

Unfortunately there is a bug with the tutorial code. 

Under the section “Listing the Contacts” you’ll find the following code for the Controllers\HomeController.cs file:

 

public class HomeController : Controller
{

private ContactManagerDBEntities _entities = new ContactManagerDBEntities();

//
// GET: /Home/

public ActionResult Index()
{
return View(_entities.ContactSet.ToList());
}

 

If you’re following the tutorial and try to build the solution you’ll then get the following error:

“The type or namespace name 'ContactManagerDBEntities' could not be found (are you missing a using directive or an assembly reference?) “

This is because the tutorial code is missing a step.  You need to add a reference to ContractManager.Models in your declarations section at the top of Controllers\HomeController.cs:

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using ContactManager.Models;

 

Hope this helps!

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Comments

Comments are closed