Skip to content Skip to sidebar Skip to footer

Logging Sql Statements Of Entity Framework 5 For Database-first Aproach

I'm trying to use Entity Framework Tracing Provider to log the SQL staments generated. I changed my context class to something like this: public partial class MyDBContext: DbContex

Solution 1:

After modifying your code, you need to enable tracing in your web.config like this:

<?xml version="1.0" encoding="utf-8"?><configuration><system.diagnostics><sources><sourcename="EntityFramework.NorthwindEntities"switchValue="All" /></sources></system.diagnostics></configuration>

The name of your TraceSource should be your context name prefixed with 'EntityFramework'. Make sure that you disable tracing when you deploy your application to production by setting the switchValue to Off.

Post a Comment for "Logging Sql Statements Of Entity Framework 5 For Database-first Aproach"