How to fix SQL Server Data Tools error ‘Unexpected exception caught during population of source model’ in Visual Studio 2017

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”

Creating SQL schemas using Entity Framework Code First

As you might have read in my previous post, I used SQL schemas to partition data between tenants. Being part of the true definition of SaaS, a new tenant should be up and running within minutes without any human intervention. With my suggested approach, we need to do two things:

  • Registering a new tenant
  • Attaching users to the tenant

In this article, I am going to focus on the first item whereas the second one shouldn’t be a big deal if you are planning to create software as a service.