views:

363

answers:

2

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

A: 

Well, WelcomeToJerome.Models is a namespace from some assembly, which must be referenced in your Web.config in order for the ASP.NET compiler to find it. You don't show the Web.config, but I'm betting the assembly isn't properly referenced there.

Craig Stuntz
A: 

Try capitalizing the B, judging by your table name, it should be Business instead of business.

Nick Craver