【发布时间】:2014-08-14 22:13:33
【问题描述】:
具有 4 层的分层应用程序,例如:
Presentation layer (MVC4)
Business layer (C# library project)
Data Access layer (c# library project)
Model layer (c# library project that contains models, EF dbcontext, etc)
所以在这个应用程序上,模型层包含 EF 数据库上下文、一些自定义模型和其他类似的东西,数据访问层包含对 ef 的查询和一些对数据库的直接查询,业务层包含业务逻辑和表示是一个mvc4项目。
业务、数据和模型层是库项目。
mvc4 presentation layer has references to BL and ML.
BL has references to DAL and ML.
DAL has references to ML.
所以问题是:我应该将字符串连接和全局变量保存在哪里? 而最重要的是怎么做?
我应该将它们保存在 mu mvc4 应用程序的 web.conf 中吗?如果是,ML如何访问它?
还是应该在 ML 上?
【问题讨论】:
-
连接字符串应该放在 MVC 项目中。当您将连接名称提供给 DbContext 时,只需按名称使用它。
标签: c# entity-framework asp.net-mvc-4 connection-string n-tier-architecture