开发者

What would cause "Name Model is not declared" inside an ASP.NET MVC project?

开发者 https://www.devze.com 2023-03-07 07:03 出处:网络
I have a class library that has an ado.net entity data model and some repository classes to interact with the data.I added a reference to this class library in my MVC project.When I create a strongly

I have a class library that has an ado.net entity data model and some repository classes to interact with the data. I added a reference to this class library in my MVC project. When I create a strongly typed view in the MVC project, I have the option of selecting one of the classes from my class library reference. The view is created successfully and inherits from System.Web.Mvc.ViewUserControl(Of IEnumerable (Of MyClassLibraryNamespace.MyClass)). So far so good - but the Model object in the view is not recognized. In the view, the line of code "For each item in Model" will not compile because "Model is not declared." Can I not base a 开发者_高级运维view on an object outside of the current project?


Yes you can use an object outside of the current project. You need to make sure you have put a reference to that other project (assembly) in your web projects references to do this though.

0

精彩评论

暂无评论...
验证码 换一张
取 消