【发布时间】:2013-03-20 08:17:21
【问题描述】:
所以我是相当新的 MVC4,许多模式对我来说都是新的。
不过,我很好奇的一件事是关于发布/调试模式的最佳实践。 对我来说,实时模式和调试模式之间有很多不同之处,我希望所有这些都是自动的,因此我不需要更改任何内容即可发布。
例如,我在我的 repo(域项目)中做了这样的事情 公共类 EFAccountRepository : IAccountRepository { 私有 EFDbContext _context;
public EFAccountRepository()
{
#if DEBUG
_context = new EFDbContext("name=Debug");
#else
_context = new EFDbContext("name=Live");
#endif
}
在我的 DI (webui) 中就像这样
#if DEBUG
EFDbContext efcontext = new EFDbContext("name=Debug");
#else
EFDbContext efcontext = new EFDbContext("name=Live");
#endif
或者简单地拥有会更聪明
EFDbContext efcontext = new EFDbContext("name=MyApp");
然后用web.config改变一下myApp是什么意思?
热烈欢迎任何其他自动化调试/发布发布的技巧。
【问题讨论】:
标签: entity-framework deployment release release-management profiles