本文介绍了如何在aspnet vnext config.json文件中配置Entity Framework拦截器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Web配置文件中,我会这样做:

In a web config file, I would do this:

<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>

<interceptors>
  <interceptor type="System.Data.Entity.Infrastructure.Interception.DatabaseLogger, EntityFramework">
    <parameters>
      <parameter value="C:\tmp\DataAccessLogOutput.txt" />
    </parameters>
  </interceptor>
</interceptors>
</entityFramework>

但是我如何在vnext的config.json中做到这一点:

But how do I do it in vnext's config.json:

{
    "Data": {
        "DefaultConnection": {
            "ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=aspnet5-Cupcake-a652ca1c-0d92-4155-ad46-bfb68bb538ee;Trusted_Connection=True;MultipleActiveResultSets=true"
        }
    },
    "EntityFramework": {
        "ApplicationDbContext": {
            "ConnectionStringKey": "Data:DefaultConnection:ConnectionString",
        }
    }
}

推荐答案

我实际上认为该功能在EF7中尚不存在.它正在积压中,但似乎尚未实现.

I actually think the functionality does not exist yet in EF7. It's on the backlog but does not seem to be implemented yet.

https://github.com/aspnet/EntityFramework/issues/1629

这篇关于如何在aspnet vnext config.json文件中配置Entity Framework拦截器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 02:35