Hi,
I'm using Visual Studio 2010 pro, and i'd like to be able to trace the sql generated by the entity framework.
Code:
Using ce As New MyDataEntities
Dim f = (From c In ce.MYTABLEs
Where c.IYEAR = iy And c.ISEQUENCE = isq
Select c.IS_PRINTED).SingleOrDefault
Dim sqlString As String = " "
sqlString = TryCast(f, System.Data.Objects.ObjectQuery).ToTraceString
If f = 0 Or f Is Nothing Then
r = False
Else
r = True
End If
End Using
The query without the trace works fine, but when I add:
Code:
sqlString = TryCast(f, System.Data.Objects.ObjectQuery).ToTraceString
I get an error: Object reference not set to an instance of an object. is there another way I should be tracing this?
Thanks.