For the last few days I’ve been getting an error when comparing database schemas in Visual Studio using the SQL Server Data Tools:

“Unexpected exception caught during population of source model: Object reference not set to an instance of an object”

Here’s how it looks like in Visual Studio 2017 (15.8.6) and SQL Server Data Tools (15.1.61808.07020):

ssdt_error

There is a temporary workaround to this problem:

  • Open the select target dropdown:

    ssdt_error_2

  • This will open a window. Tick the database radiobutton and click the ‘Select Connection’ button:

    ssdt_error_3.png

  • In the History tab, locate the database you want to target, right click and select ‘Remove from History’:

    ssdt_error_4.png

  • Click cancel
  • Close the SqlSchemaCompare window

Now when selecting a target, you need to locate your database in the Browse tab. When you selected your database you can hit the ‘Compare’ button in the SqlSchemaCompare window.

You may have to retry this process a couple of times before it works.

If you know the actual root cause and solution for this problem you can always make a comment. But so far this has consistently helped me.

 

 

 

Leave a Reply