构建 Rails 应用程序和 ASP.NET MVC 应用程序之间的区别?
首先是一些背景知识:4 年 C# 经验和一年 Rails 经验。如果有人曾在这两个领域工作过并且对开发 ASP.NET MVC 应用程序有很多了解,我将不胜感激。
去年我除了 Rails 项目什么也没做。现在,我有一个客户希望他们的应用程序从 ASP.NET Web 窗体转换为 ASP.NET MVC。这是我第一次在 C# 中完成 MVC,因此我试图看看有什么不同,以及某些高效的 Rails 任务是否映射到 ASP.NET MVC。
首先,ASP.NET MVC中有没有Scaffold这样的东西?我看到一个叫做 Area
的东西,但我不知道这是否正是我想要的。另外,我如何生成一个脚手架(模型、控制器和视图)、一个控制器或一个基于我为 Rails 应用程序提供的相同信息的模型?
例如,我可能会做类似的事情:
$>script/generate scaffold person first_name:string last_name:string
生成一个 Person
模型、一个迁移脚本(我运行它来构建数据库表)、一个 People
控制器和每个的视图REST
完整接口(index
、new
、create
、edit
、>更新
、显示
、销毁
)。我可以在 Visual Web Develop 2010 Express 中执行类似的操作吗?
First of all some background: 4 years of C# experience and a year of Rails experience. I would appreciate any input from someone who has worked in both and knows a lot about developing ASP.NET MVC applications.
I've been doing nothing but Rails projects for the last year. Now, I have a client wants their application converted from ASP.NET Web Forms to ASP.NET MVC. This is the first time I've done MVC in C# so I'm trying to see how different things are and if certain productive Rails tasks map over to ASP.NET MVC.
First of all, is there such a thing as a Scaffold
in ASP.NET MVC? I see something called an Area
but I don't know if thats quite what I want. Also, how can I generate a scaffold (models, controllers and views), just a controller or just a model based on the same information I would give a Rails app?
For example I might do something like:
gt;script/generate scaffold person first_name:string last_name:string
which produces a Person
model, a migration script (what I run to build the database table), a People
controller and views for each of the REST
ful interfaces (index
, new
, create
, edit
, update
, show
, destroy
). Can I do something like this in Visual Web Develop 2010 Express?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MVC 脚手架有 MVC3。
这是一个不错的帖子。
There is MVC Scaffolding with MVC3.
Here's a nice post on it.
Rails 尝试(特别是对于初学者)引导您以一种方式编写应用程序,而 MVC 则试图满足所有人的需求。所以它非常灵活,但很难指定“一种真正的方法”来构建某些东西。
因此,有效的一种方法是:
但还有很多其他方法!
有用于迁移的第 3 方工具,但没有任何内置工具。完整 VS 中内置的(可能不是明确的)是数据库比较和合并脚本生成,可以说更强大,但对于新开发人员来说可能更困难理解,替代。
Whereas Rails has tries (especially for beginners) to guide you into one way to write your app, MVC attempts to be all things to all people. So it's very flexible, but it's hard to specify the "one true way" to scaffold something.
So one way which works is:
But there are many other ways!
There are 3rd party tools for migrations, but nothing built in. What is built into full VS (maybe not express) is database comparison and merge script generation, an arguably more powerful, but perhaps harder for new developers to understand, alternative.