I understand that this similar question was asked several times, and I unsuccessfully tried recommendations in these questions.
I use the entity framework (4.3) and work against SQL Azure (in the federated database). I would like to be able to register the SQL that is generated by the entity framework.
I used the Entity Profiler Framework , and although this is useful during development, I am not sure if this would be useful during production.
I cannot use SQL Profiler as it is an Azure SQL Database.
I tried using EFTracingProvider and followed the steps here . Unfortunately, when I try to execute my first command (which uses the appropriate federation), I get an exception indicating that "The specified method is not supported."
The code that generates the error is as follows:
public MyContext(int tenantId) : base(CreateTracingConnection("TheDb"), true) { const string FederationCmdText = "USE FEDERATION TenantFederation(CustomerId = {0}) WITH RESET, FILTERING=ON"; ((IObjectContextAdapter)this).ObjectContext.EnableTracing(); ((IObjectContextAdapter)this).ObjectContext.Connection.Open();
Here's the exception:
Specified method is not supported. at EFProviderWrapperToolkit.DbConnectionWrapper.CreateDbCommand() at System.Data.Common.DbConnection.CreateCommand() ...
So here are my questions:
- Is EFTracingProvider preferable for logging SQL queries (globally)?
- If yes, any ideas why I get the exception above?
- If not, is there another mechanism that will allow me to register all the SQL generated by the Entity Framework?
Thanks for your help, Eric.
source share