构建 Rails 应用程序和 ASP.NET MVC 应用程序之间的区别?

发布于 2024-10-12 04:25:01 字数 785 浏览 3 评论 0原文

首先是一些背景知识: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完整接口(indexnewcreateedit>更新显示销毁)。我可以在 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 RESTful interfaces (index, new, create, edit, update, show, destroy). Can I do something like this in Visual Web Develop 2010 Express?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤云独去闲 2024-10-19 04:25:01

MVC 脚手架有 MVC3。

这是一个不错的帖子。

There is MVC Scaffolding with MVC3.

Here's a nice post on it.

素手挽清风 2024-10-19 04:25:01

Rails 尝试(特别是对于初学者)引导您以一种方式编写应用程序,而 MVC 则试图满足所有人的需求。所以它非常灵活,但很难指定“一种真正的方法”来构建某些东西。

因此,有效的一种方法是:

  1. 创建数据库。以通常的方式从数据库创建实体框架模型。
  2. 编译。
  3. 右键单击“控制器”、“添加”、“控制器”。选中操作框。
  4. 右键单击生成的操作之一,选择“添加视图”。
  5. 选中“创建强类型视图”框,然后从组合框中选择脚手架。

但还有很多其他方法!

有用于迁移的第 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:

  1. Create your DB. Create an Entity Framework model in the usual way from the DB.
  2. Compile.
  3. Right-click Controllers, Add, Controller. Check the box for actions.
  4. Right click one of the generated actions, choose Add View.
  5. Check the box for "Create strongly typed view" and select scaffolding from the combo box.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文