View Generated SQL in Entity Framework (EF)

Hey everyone,

Just a quick post on how to view the generated sql in entity framework. To start with, just add the following line to your db context constructor:

public class TestDbContext : DbContext
    {
        public TestDbContext() : base("name=TestDbContext")
        {
            this.Database.Log = s => System.Diagnostics.Debug.WriteLine(s); //This line
        }
        ...

With this line added, you should now be able to see all of your generated sql in the output window.

SELECT TOP (1) 
    [Project1].[VidId] AS [VidId], 
    [Project1].[CreatedAt] AS [CreatedAt], 
    [Project1].[Check] AS [Check], 
    [Project1].[SourceCheck] AS [SourceCheck]
    FROM ( SELECT 
        [Extent1].[VidId] AS [VidId], 
        [Extent1].[CreatedAt] AS [CreatedAt], 
        [Extent1].[Check] AS [Check], 
        [Extent1].[SourceCheck] AS [SourceCheck]
        FROM [dbo].[Vids] AS [Extent1]
        WHERE [Extent1].[VidId] < @p__linq__0
    )  AS [Project1]
    ORDER BY [Project1].[VidId] DESC

-- p__linq__0: '535' (Type = Int32)
-- Executing at 28/06/2014 5:00:16 PM +10:00
-- Completed in 0 ms with result: SqlDataReader

If you’re not using EF6, there were a few other options where I came across this solution: http://stackoverflow.com/a/20751723/522859

Dragging a File from File Explorer Causes Google Chrome to Crash

Hey everyone,

A team member found an interesting bug today that caused chrome to go non-responsive. The cause was simply dragging a file from the file explorer onto a drag and drop upload area. It is reproducible on every site I’ve tested, including Gmail and Dropbox.

Reproduce

  • Go to https://mail.google.com
  • Click compose
  • Click attach files (close any of the annoying popups that appear)
  • DRAG a number of files from the file selector window to the new message screen (they will start to upload) (IMPORTANT: these need to be dragged from the file selector popup, NOT a new explorer window)
  • While they are still uploading hit cancel on the file browser window. Browser will go non-responsive

A bug has been reported here: https://code.google.com/p/chromium/issues/detail?id=388661

How to Open the Same File Twice in Visual Studio

Hey everyone,

I was working on a fairly large class in visual studio and having a bit of trouble comparing two different areas within it. Thankfully, StackOverflow knew of a way to make things a lot easier – open the same file twice:

– With the tab you want to duplicate currently active, select Window from the menu
– Click new window
– On the new window, right click and select ‘New Vertical Tab Group’ from the drop down