English 中文(简体)
在主计长和 " 观点 " 之前和之后,利用 " EF VS " 项目,在监查中心增加一个模型的利弊何在?
原标题:What are pros and cons of adding a Model to MVC using EF VS project before and after a Controller and a View?

在关于利用EF(实体框架,实体框架4.1/4.2)开发MVC3(MVC2)的辅导和步行过程中,我观察到在微软视觉工作室2010年的一个项目中增加模型、View、Coveror等不同顺序。

What are cons and pros of different orders of adding M, V and Cs?
and of, for example, adding a model before and, more specifically, after a view and controller?

最佳回答

没有先添加一条规则。 当您创建空 ASP. NET MVC3 工程时, 它会包含一个默认文件夹结构, 包括一个 < engy > 主计长 文件夹、 < engy> Option 文件夹和 < engy > Models 文件夹 。

如果您是初学者, 这就是我的建议。 先添加一个 < code> 控制器 < / code > 。

鼠标右键点击他 主计长 文件夹,并从上下文菜单中选择 Add- > 并添加第一个控制器(将名称以 Homecurrent 命名) 。 它会带有默认 Index 动作方法, 您可以看到回视图语句。 现在运行您的工程。 它会显示一个错误, 显示它无法找到一个视图。 因此现在是时候添加一个视图了。 在主控制器中选择索引动作。 右键点击 < code> return View () 语句, 并选择在视图下主文件夹中添加视图( index. xshtml) 的添加视图。 现在运行该应用程序, 您将会看到页面内容 。

如果您要与数据库互动,可以添加模式类。如果您可以将 POCO 类文件添加到您的 Models 文件夹中,或者您可以将它放在另一个库中,该库被引用到此 projcet。这一切都取决于您。

Lavinski 提到, 如果您先创建您的模型, 您可以先使用脚手架为您创建控制器动作。 < 坚固> 但是, 如果您是初开始者, 我建议您用手创建您的控制器和视图 < / 坚固 > 。 这将帮助您理解 MVC < code> 配置 工作

问题回答

暂无回答




相关问题
WebForms and ASP.NET MVC co-existence

I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...

Post back complex object from client side

I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...

Create an incremental placeholder in NHaml

What I want to reach is a way to add a script and style placeholder in my master. They will include my initial site.css and jquery.js files. Each haml page or partial can then add their own required ...

asp.net mvc automapper parsing

let s say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; ...

structureMap mocks stub help

I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...

ASP.NET MVC: How should it work with subversion?

So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...