简体   繁体   中英

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?

I would suggest using something like you have already (http://npgsql.projects.postgresql.org/), and then you can leverage your existing framework/infrastructure (how you query your database from your existing application).

Secondly, If you are using DataGridViews and TabControls, ASP.NET MVC doesn't really work with server controls, you will either have to get an HtmlHelper that gives you a grid, or build one yourself.

The question I think that needs to be asked is, why do you want to go MVC vs WebForms 4.0?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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