修改代码后,您需要像这样在web.config中启用跟踪:
<?xml version="1.0" encoding="utf-8"?><configuration> <system.diagnostics> <sources> <source name="Entityframework.NorthwindEntities" switchValue="All" /> </sources> </system.diagnostics></configuration>
TraceSource的名称应为您的上下文名称,前缀为“
Entityframework”。通过将设置为
switchValue,确保在将应用程序部署到生产环境时禁用跟踪
Off。



