zoukankan      html  css  js  c++  java
  • 记录entityframework生成的sql语句

    Interceptors (EF6.1 Onwards)

    Starting with EF6.1 you can register interceptors in the config file. Interceptors allow you to run additional logic when EF performs certain operations, such as executing database queries, opening connections, etc.

    Interceptors are registered by including an interceptor element under the interceptors child section of the entityFramework section. For example, the following configuration registers the built-in DatabaseLogger interceptor that will log all database operations to the Console.

    <interceptors> 
      <interceptor type="System.Data.Entity.Infrastructure.Interception.DatabaseLogger, EntityFramework"/> 
    </interceptors>

    Logging Database Operations to a File (EF6.1 Onwards)

    Registering interceptors via the config file is especially useful when you want to add logging to an existing application to help debug an issue.DatabaseLogger supports logging to a file by supplying the file name as a constructor parameter.

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

    By default this will cause the log file to be overwritten with a new file each time the app starts. To instead append to the log file if it already exists use something like:

    <interceptors> 
      <interceptor type="System.Data.Entity.Infrastructure.Interception.DatabaseLogger, EntityFramework"> 
        <parameters> 
          <parameter value="C:TempLogOutput.txt"/> 
          <parameter value="true" type="System.Boolean"/> 
        </parameters> 
      </interceptor> 
    </interceptors>

    For additional information on DatabaseLogger and registering interceptors, see the blog post EF 6.1: Turning on logging without recompiling.

  • 相关阅读:
    SpringApplication类-1
    post与head注入
    sql_post注入
    渗透测试点线面合集
    渗透入侵溯源
    VMware 安装Tools 失败的问题:VGAuthService 启动失败
    Weblogic wls-wsat XMLDecoder 反序列化漏洞复现(CVE-2017-10271)
    web常见的中间件漏洞及复现
    XX点评H5字体映射
    python控制阿里云服务器开机,关机,重启
  • 原文地址:https://www.cnblogs.com/loui/p/entityframework.html
Copyright © 2011-2022 走看看