使用现有 Postgres 数据库的 MVC3 数据库访问
我有一个基于 3 层架构的应用程序,其中包含 400 多个存储过程的 postgres 数据库(npgsql),现在我想使用 MVC3 框架开发相同的应用程序。
我想知道将现有数据库与这些存储过程一起使用的最佳方法是什么,我遇到过代码优先方法(http://weblogs.asp.net/scottgu/archive/2010/08/03/using- ef-code-first-with-an-existing-database.aspx),但想知道这是否是最佳解决方案。
我还了解了 Razor 的优点,但是我的应用程序有很多 DataGridView 和 TabContorls,所以我想知道使用 Razor 是否容易?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您必须决定使用 MVC3 开发现有应用程序所需的重构级别或转换级别,因为您可能会放弃大部分工作,
原因如下:
使用 MVC 作为技术与 DDD 存在某种关联作为 OOP 设计或普通 OOP,在这两种方法中,主要层是域模型而不是数据库,因此您需要将所有存储过程转换为域模型本身内部的业务逻辑,或者使用现有的数据库,在这种情况下你将失去使用的一大好处MVC
在表示层中使用 MVC 时不考虑使用 DataGridViews 或 TabContorls,因此您也需要扔掉它们,并且没有解决方案可以重用它们。
最后,使用 MVC 的主要好处是 MVC 提供的单元测试能力和高水平的可维护性,因为模式和方法本身的性质>
所以你必须认真思考你想要达到什么水平的转变,以决定你将保留什么以及你将丢弃什么,但我建议你,如果你真的不会重组整个项目,就不要转变为 MVC,只需保持项目原样,重构它并增强现有方法
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
我建议使用您已经拥有的东西(http://npgsql.projects.postgresql.org/),然后您可以利用现有的框架/基础设施(如何从现有应用程序查询数据库)。
其次,如果您使用 DataGridViews 和 TabControls,ASP.NET MVC 并不真正与服务器控件一起工作,您要么必须获得一个为您提供网格的 HtmlHelper,要么自己构建一个。
我认为需要问的问题是,为什么要选择 MVC 而不是 WebForms 4.0?
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?