How do I view the SQL generated by the Entity Framework?

后端 未结 22 2711
别那么骄傲
别那么骄傲 2020-11-21 05:35

How do I view the SQL generated by entity framework ?

(In my particular case I\'m using the mysql provider - if it matters)

22条回答
  •  南笙
    南笙 (楼主)
    2020-11-21 06:25

    I've just done this:

    IQueryable query = EntitySet.Where(p => p.Id == id);
    Debug.WriteLine(query);
    

    And the result shown in the Output:

    SELECT 
        [Extent1].[Id] AS [Id], 
        [Extent1].[Code] AS [Code], 
        [Extent1].[Name] AS [Name], 
        [Extent2].[Id] AS [Id1], 
        [Extent2].[FileName] AS [FileName], 
        FROM  [dbo].[Products] AS [Extent1]
        INNER JOIN [dbo].[PersistedFiles] AS [Extent2] ON [Extent1].[PersistedFileId] = [Extent2].[Id]
        WHERE [Extent1].[Id] = @p__linq__0
    

提交回复
热议问题