【问题标题】:How do I configure an Entity Framework interceptor in an aspnet vnext config.json file?如何在 aspnet vnext config.json 文件中配置实体框架拦截器?
【发布时间】:2015-04-16 01:34:54
【问题描述】:

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

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

【问题讨论】:

  • 很遗憾,大多数 vnext 内容的文档记录都很差。我一直在寻找这样的问题,完全没有答案,而且在网络上的任何地方都没有任何文档。这是一个失望。因为我真的认为这个 json 的东西可以比 web.config 更好,但是没有文档它是完全没用的。
  • @RobertNoack 这就是测试版软件的诅咒。
  • @Josh:能找到答案吗?

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


【解决方案1】:

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

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

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-31
相关资源
最近更新 更多