Search code examples
asp.net-mvcasp.net-mvc-3postgresqlrazornpgsql

MVC3 database access using existing Postgres database


I have an application based on 3 tier architecture with postgres database(npgsql) having more than 400 stored procedures, And now i want to develop the same application using MVC3 Framework.

I would like to know whats the best possible way to use the existing database with those stored procedures, I have come across code first approach (http://weblogs.asp.net/scottgu/archive/2010/08/03/using-ef-code-first-with-an-existing-database.aspx) but would like to know if its the best solution.

Also i read about benefits of Razor however my application has lots of DataGridViews and TabContorls so i was wondering would it be easy to go with Razor?


Solution

  • First you have to decide what level of refactor or the transformation level you need to go with developing your existing application using MVC3, because you probably will throw most of your work

    Because of the following:

    Working with MVC as technology is related some how with DDD as OOP design or normal OOP, and in both approaches the main layer is the Domain Model not the DB, so you will need to translate all your stored procedures to business logic inside the Domain Model itself or otherwise use the existing DB and in this case you will lose one of the big benefit of using MVC

    Working with MVC in the presentation layer not consider working with DataGridViews or TabContorls, so you will need to throw them too, and there is no solution to re-use them.

    At the end, the main benefits of using MVC,,are the capability of unit testing and the high level of maintainability that MVC provide, because the nature of the pattern and the approach itself>

    So you have to really think very good of what level of transomation you want to achieve to decide what you will keep and what you will throwaway, but my advise to you if you really will not restructure your whole project don't transform to MVC, just keep the project as it's and just refactor it and enhance the existing approach