开发者

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. 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:

$>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 RESTf开发者_如何学编程ul interfaces (index, new, create, edit, update, show, destroy). Can I do something like this in Visual Web Develop 2010 Express?


There is MVC Scaffolding with 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. 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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜