1

The biggest thing I miss from Rails is the super handy console.

Let's say you need to call a certain function on the server that will update the database. In Rails, you just launch the console and call it.

In ASP.NET MVC I have to call it in a controller, rebuild the whole solution, transfer the compiled dll to the server, go to the page that has to call the function (it has to be protected of course), and it's done.

So is there an alternative?

Thank you

Alex
  • 34,581
  • 26
  • 91
  • 135

3 Answers3

1

I don't know of anything like console for asp.net. But I do know of an alternative to what you're doing because I used to do similar things all the time.

You don't have to upload the newly compiled solution to the server. All you have to do is change your connection string from development to production. Then just run it locally and your production database will be updated.

To organize things a little better I had an admin page where I could do various database management tasks. I'd just create button links on the page for whatever it was I needed to do and all the actions were placed in an admin controller. I set the permissions on that controller so that only an admin could access the actions.

On a side note, why are you going from rails to asp.net MVC? I did asp.net for a few years and rails for a few months now. I find I prefer rails these days a lot more.

Edit: (if you need something quick and dirty)

  1. add a button on one of your existing pages linked to a controller action
  2. point your connection string to the production database
  3. run locally and click the button

Afterwards, remove or comment out the code you just ran.

Dty
  • 12,253
  • 6
  • 43
  • 61
  • After several months of Ruby programming I decided that I prefer static typed languages :) Besides I need performance, and .NET is a lot faster than Rails. Yes, I also have admin pages for several tasks, but sometimes you need to do something special, and there's no time to make a separate page for it. – Alex Feb 12 '11 at 17:00
  • Edited my answer for a quick and dirty way to get something done. – Dty Feb 13 '11 at 01:34
  • @Dty - LINQpad is your alternative, see answer below – Lloyd Feb 23 '12 at 09:25
0

There is no console per-se built in in ASP.NET (although there is one in Visual Studio) but if your models are independent of the rest of the system you should be able to call them from a command line application (or even a Visual Studio unit test) really quickly.

Hector Correa
  • 26,290
  • 8
  • 57
  • 73
0

LINQPad makes an excellent equivalent to Rails Console.. Instructions here: https://stackoverflow.com/a/9403457/1029644

Community
  • 1
  • 1
Lloyd
  • 8,204
  • 2
  • 38
  • 53