EF6中的SQL監控

在MVC或WEBAPI中的監控

System.Action<string> action = (string message) => { Debug.WriteLine(message); };
Context.Database.Log = action;

參考:

Logging Database Commands in Entity Framework(在EF框架中記錄數據庫命令):
https://www.entityframeworktutorial.net/entityframework6/database-command-logging.aspx
Logging and intercepting database operations(日誌記錄和攔截數據庫操做)
https://docs.microsoft.com/en-us/ef/ef6/fundamentals/logging-and-interceptionweb

相關文章
相關標籤/搜索