如何在aspnet vnext config.json文件中配置实体框架拦截器?

时间:2015-02-15 12:51:21

标签: asp.net-core entity-framework-core

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

<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中执行此操作:

{
    "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",
        }
    }
}

1 个答案:

答案 0 :(得分:1)

我实际上认为EF7中还没有这种功能。这是积压的,但似乎还没有实施。

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