2
花费了更好的时间来梳理SO。这里的设置如何获得在EF 4.1上工作的MVC-mini-profiler数据库优先
- MVC 3应用程序使用存储库模式与跨3个数据库存储库。
- EF 4.1数据库首先将DBContext API用于两个数据库连接。
- 安装了的NuGet MVC-迷你探查
这是我如何控制器
public class InvoiceController : BaseController
{
private ITransactionRepository _txnRepository;
public InvoiceController()
{
_txnRepository = new TransactionRepository();
}
public InvoiceController(ITransactionRepository t)
{
_txnRepository = t;
}
}
最后,在存储库中创建我的数据库上下文
public class TransactionRepository : BaseRepository, ITransactionRepository
{
AccountingEntities _db = new AccountingEntities();
// repository methods
}
以后,我添加到web.config中
<system.data>
<DbProviderFactories>
<remove invariant="MvcMiniProfiler.Data.ProfiledDbProvider" />
<add name="MvcMiniProfiler.Data.ProfiledDbProvider" invariant="MvcMiniProfiler.Data.ProfiledDbProvider" description="MvcMiniProfiler.Data.ProfiledDbProvider" type="MvcMiniProfiler.Data.ProfiledDbProviderFactory, MvcMiniProfiler, Version=1.8.0.0, Culture=neutral, PublicKeyToken=b44f9351044011a3" />
</DbProviderFactories>
</system.data>
分析这些连接的下一步是什么?因为这是我第一次接触实体框架,所以慢慢走我,所以对于EF连接/上下文详细信息的假设很少。
感谢萨姆,头发更与1.9.1拉动。伟大的更新。 – RyanW
只是想添加MiniProfiler.MVC3 nuget包,即使这不是必需的。 只需在您的MVC3项目中安装MiniProfiler.MVC3包,取消App_Start \ MiniProfiler.cs中的MiniProfilerEF.Initialize()调用的注释,并参考自动添加的示例布局文件以获取修改自己的提示。 –