如何获取由实体框架生成的sql [英] How to get the sql generated by the entity framework

查看:61
本文介绍了如何获取由实体框架生成的sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取实体框架查询生成的sql脚本?
ie如果我写

How can I get the sql script generated by an entity framework query? i.e. If I write

entityDataDontext.table1.Where(r => r.primarykey == 1).First();

那么我该如何获得应该有点像这样的SQL:

then how can I get the SQL which should be somewhat like this:

select * from table1 where primarykey = 1

提前感谢:)

推荐答案

当您将SQL Server作为后端数据库时, SQL Server Profiler 始终是查看正在发送到要处理数据库的SQL语句的最佳工具。

When you're going against SQL Server as your backend database, SQL Server Profiler is always the best tool to see exactly what SQL statements are being sent to your database to be processed.

请参阅介绍SQL Server Profiler 的背景信息。

这篇关于如何获取由实体框架生成的sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆