本文转自:https://stackoverflow.com/questions/44202478/lost-parameter-value-during-sql-trace-in-ef-core

问:

I have implemented an approach for tracing SQL queries from EF Core according to this article: https://docs.microsoft.com/en-us/ef/core/miscellaneous/logging.

And have problems with tracing query parameteres.

When I recive Log event in all values of DbParameterLogData

I see only the question mark instead of the actual values wich I passed to the query. Example image VS 2015. Thank you!

答:

This is the default behavior of EF Core (filling up the DbParameterLogData.Value property with "?").

In order to get the real parameter values, you need to enable sensitive data logging by using DbContextOptionsBuilder.EnableSensitiveDataLogging method:

Enables application data to be included in exception messages, logging, etc. This can include the values assigned to properties of your entity instances, parameter values for commands being sent to the database, and other such data. You should only enable this flag if you have the appropriate security measures in place based on the sensitivity of this data.

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.EnableSensitiveDataLogging();
// ...
}

 

Sometimes this results in a MissingMethodException.

In which case, you should call it in ConfigureServices():

services.AddDbContext<MyDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("Defa‌​ultConnection")).Ena‌​bleSensitiveDataLogg‌​ing()) – yfisaqt Jul 6 at 21:10

[转]Lost parameter value during SQL trace in EF Core DbParameter 为 问号 ?的更多相关文章

  1. EF Core 2.1 Raw SQL Queries (转自MSDN)

    Entity Framework Core allows you to drop down to raw SQL queries when working with a relational data ...

  2. Oracle sql trace

    一.SQL_TRACE说明 1.1.在全局启用 在参数文件(pfile/spfile)中指定:sql_trace =true 1.2.在当前session级设置 启用当前session的跟踪: alt ...

  3. SQL Server 扩展事件(Extented Events)从入门到进阶(1)——从SQL Trace到Extented Events

    由于工作需要,决定深入研究SQL Server的扩展事件(Extended Events/xEvents),经过资料搜索,发现国外大牛的系列文章,作为“学习”阶段,我先翻译这系列文章,后续在工作中的心 ...

  4. SQL TRACE

    1.SQL TRACE说明: 参数类型 布尔型 缺省值 false 参数类别 动态 取值范围 True|false 2.类型 1)sql trace参数:alter system改变对全局进程影响,如 ...

  5. PLSQL_性能优化效能跟踪工具SQL Trace分析(案例)

    2014-06-25 Created By BaoXinjian

  6. SAP 使用SQL Trace(ST05)

    SAP 使用SQL Trace(ST05) SAP R/3 提供标准ABAP SQL 跟踪工具.使用T-Code:ST05 可以进入追踪设定画面:          在Trace Modes 区域中选 ...

  7. Oracle 11g R2性能优化 SQL TRACE

    作为Oracle官方自带的一种基本性能诊断工具,SQL Trace可以用来评估当前正在运行的SQL语句的效率,同时为该语句生成统计信息等,并保存这些信息到指定路径下的跟踪文件(trace)当中.SQL ...

  8. Oracle核心技术之 SQL TRACE

    1.SQL TRACE说明: 参数类型 布尔型 缺省值 false 参数类别 动态 取值范围 True|false 2.类型 1)sql trace参数:alter system改变对全局进程影响,如 ...

  9. SQL Server Extended Events 进阶 1:从SQL Trace 到Extended Events

    http://www.sqlservercentral.com/articles/Stairway+Series/134869/ SQL server 2008 中引入了Extended Events ...

随机推荐

  1. [ASP.NET]uploadify简单使用讲解

    背景:在用户控件中使用html 的file控件或者ASP.NET的FileUpLoad控件都无法获取到文件,于是想到听说过的uploadify uploadify官网:www.uploadify.co ...

  2. 学习sqlserve的一些笔记

    创建表: create table 表名 { //定义列名 id ,) primary key,//自动编号:从1开始每次增长1,约束:主键约束 name ) not null //非空约束 } 表数 ...

  3. C#之使用AutoUpdater自动更新客户端

    安装NuGet包 在Visio studio中右击解决方案,选择管理NuGet包,搜索安装Autoupdater.NET.Official. 工作简介 从服务器下载包含更新文件的XML文件,从中获取软 ...

  4. 无废话网页重构系列——(3)Web重构前的分析

    本篇讲重构前的分析.从“工作状态.工作环境和工作角色”和具体重构工作两方面分析. 凡是经过考验的朋友,就应该把他们紧紧地团结在你的周围 比较理想的工作状态:制定了各种设计和开发规范,各团队之间邮件.团 ...

  5. 【大数据之数据仓库】kudu性能测试报告分析

    本文由  网易云发布. 这篇博文主要的内容不是分析说明kudu的性能指标情况,而是分析为什么kudu的scan性能会这么龊!当初对外宣传可是加了各种 逆天黑科技的呀:列独立存储.bloom filte ...

  6. OpenStack 数据库操作 demo

    #!/usr/bin/env python from sqlalchemy.orm import sessionmaker from sqlalchemy import create_engine f ...

  7. Segment Tree-732. My Calendar III

    Implement a MyCalendarThree class to store your events. A new event can always be added. Your class ...

  8. 怎样使用Navicat Premium导出导入mysql数据库

    首先,在Navicat Premium中连接要导出数据库的mysql数据库. 2 1.填写好连接数据库的信息后就可以连接到需要导出的数据库了. 3 打开要导出的数据库. 4 将数据库的结构和数据导出为 ...

  9. 【xsy1237】 字符转换 矩阵快速幂

    题目大意:给你两个长度都为n,字符集为{a,b,c}的字符串S和T. 对于字符串S的任意一个字符,我们可以用cost[0]的代价,把字符a变成字符b.用cost[1]的代价,把字符b变成c,用cost ...

  10. 【bzoj2789】 Letters 树状数组

    又是一道树状数组求逆序对的题目. 这一题我们可以将第二个串中的每一个字母,与第一个串中的字母做两两匹配,令第二个串第i个字母的值id[i]为该字母与第一个串中的字母匹配到的位置. 然后考虑到所求答案为 ...