如何配置 MvcMiniProfiler 以使用具有域布局的实体框架
我将 MVCMiniProfiler 与实体框架一起使用,我看到我可以像这样配置来获取对象上下文:
var connectionString = ConfigurationManager.ConnectionStrings["MyDBEntities"].ConnectionString;
var entityConnStr = new EntityConnectionStringBuilder(connectionString);
var connection = new SqlConnection(entityConnStr.ProviderConnectionString);
var profiledConnection = ProfiledDbConnection.Get(connection, MiniProfiler.Current);
var objectContext = ObjectContextUtils.CreateObjectContext<MyModel>(profiledConnection);
问题是我在解决方案的另一个项目中有一个域模型,并且我无法使用此方法。我还在我的存储库中使用依赖注入:
public MyController(IEntities repository)
{
_repository = repository;
}
我正在寻找一种配置 MvcMiniProfiler 的方法。
I would use MVCMiniProfiler with Entity Framework, I saw that I could configure like this to get the object context :
var connectionString = ConfigurationManager.ConnectionStrings["MyDBEntities"].ConnectionString;
var entityConnStr = new EntityConnectionStringBuilder(connectionString);
var connection = new SqlConnection(entityConnStr.ProviderConnectionString);
var profiledConnection = ProfiledDbConnection.Get(connection, MiniProfiler.Current);
var objectContext = ObjectContextUtils.CreateObjectContext<MyModel>(profiledConnection);
The problem is that I have a my domain model in another project of the solution and I can't use this method. I also use dependency injection for my repository:
public MyController(IEntities repository)
{
_repository = repository;
}
I am looking for a way to configure MvcMiniProfiler.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论