简体   繁体   English

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

[英]The difference between building a Rails application and an ASP.NET MVC Application?

First of all some background: 4 years of C# experience and a year of Rails experience. 首先是一些背景:4年的C#经验和一年的Rails经验。 I would appreciate any input from someone who has worked in both and knows a lot about developing ASP.NET MVC applications. 我将非常感谢任何曾在两者中工作并且对开发ASP.NET MVC应用程序有很多了解的人的意见。

I've been doing nothing but Rails projects for the last year. 去年我一直在做Rails项目。 Now, I have a client wants their application converted from ASP.NET Web Forms to ASP.NET MVC. 现在,我有一个客户端希望他们的应用程序从ASP.NET Web Forms转换为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. 这是我第一次在C#中完成MVC,所以我试图看看有多不同的东西,以及某些高效的Rails任务是否映射到ASP.NET MVC。

First of all, is there such a thing as a Scaffold in ASP.NET MVC? 首先,ASP.NET MVC中是否存在Scaffold这样的东西? I see something called an Area but I don't know if thats quite what I want. 我看到一个叫做Area东西,但我不知道那是不是我想要的东西。 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? 另外,我如何生成一个脚手架(模型,控制器和视图),只是一个控制器,或者只是基于我给Rails应用程序提供的相同信息的模型?

For example I might do something like: 例如,我可能会这样做:

$>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 ). 它生成一个Person模型,一个迁移脚本(我运行以构建数据库表),一个People控制器和每个REST ful接口的视图( indexnewcreateeditupdateshowdestroy )。 Can I do something like this in Visual Web Develop 2010 Express? 我可以在Visual Web Develop 2010 Express中执行类似的操作吗?

There is MVC Scaffolding with MVC3. MVC脚手架有MVC3。

Here's a nice post on it. 这是一篇不错的帖子。

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. 虽然Rails尝试(特别是对于初学者)来指导您编写应用程序的一种方式,但MVC试图成为所有人的所有事情。 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. 从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. 有内置的第三方工具进行迁移,但没有什么内置全VS(也许不是表达)是数据库的比较和合并脚本生成,可以说是一个更强大,但也许更加困难的新开发者理解,替代。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM