Type or namespace could not be found

Posted by Jason Shultz on Stack Overflow See other posts from Stack Overflow or by Jason Shultz
Published on 2010-03-08T23:16:22Z Indexed on 2010/03/08 23:21 UTC
Read the original article Hit count: 301

Filed under:
|
|

I'm using LINQ to SQL to connect my database to my home page. I created my datacontext (named businessModel.dbml) In it I have two tables named Category and Business.

In home controller I reference the model and attempt to return to the view the table:

var dataContext = new businessModelDataContext();
var business = from b in dataContext.Businesses
select b;
ViewData["WelcomeMessage"] = "Welcome to Jerome, Arizona!";
ViewData["MottoMessage"] = "Largest Ghost Town in America!";

return View(business);

and in the view I have this:

<%@ Import Namespace="WelcomeToJerome.Models" %>

and

<% foreach (business b in (IEnumerable)ViewData.Model)
           { %>
        <li><%= b.Title %></li>
        <% } %>

Yet, in the view business is cursed with the red underline and say's that The type or namespace name 'business' could not be found (are you missing a using directive or an assembly reference?)

What am I doing wrong? This has had me stumped all afternoon.

link to all the code in pastebin: http://pastebin.com/es4RnS2q

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about ASP.NET