Coding⏱️ 3 min read📅 2026-06-04

How to Fix: add-migration causing a "Could not load assembly" error

Error resolving assembly in Add-Migration command. Solution: Check if startup project references the correct NuGet project.

Quick Answer: Check your solution's startup project and ensure it references the NuGet project containing your migrations.

The 'Could not load assembly' error occurs when the Add-Migration command is unable to locate the specified assembly, in this case, the Registry project. This issue affects developers working with Entity Framework Core and NuGet projects within Visual Studio.

This error can be frustrating as it prevents the migration process from completing successfully. However, by following the steps outlined below, you should be able to resolve the issue and continue with your migration.

🔍 Why This Happens

  • The primary reason for this error is that the start-up project for your solution does not reference the project containing your migrations. This can happen if the NuGet projects are not properly configured or if there are naming conflicts within the solution.
  • Alternatively, it is possible that the Registry project is not correctly installed or referenced in the solution. In this case, you may need to reinstall the project or adjust its references.

🔧 Proven Troubleshooting Steps

Correcting the Start-Up Project Configuration

  1. Step 1: Step 1: Open your Visual Studio solution and navigate to the Properties window (right-click on the solution and select 'Properties').
  2. Step 2: Step 2: In the Properties window, click on the 'Startup Projects' option in the left-hand menu.
  3. Step 3: Step 3: Select the Registry project as the startup project for your solution.
  4. Step 4: Step 4: Save the changes to the solution properties.
  5. Step 5: Step 5: Try running the Add-Migration command again to see if the error persists.

Resolving Naming Conflicts or Project Issues

  1. Step 1: Step 1: Check your solution for any naming conflicts between projects. Ensure that all project names are unique and correctly referenced.
  2. Step 2: Step 2: Verify that the Registry project is installed and referenced in the solution. If not, reinstall the project or adjust its references.
  3. Step 3: Step 3: Try removing any unnecessary NuGet packages from your solution to prevent conflicts.

🎯 Final Words

By following these steps, you should be able to resolve the 'Could not load assembly' error and complete your migration successfully. Remember to regularly review your solution configuration and project references to avoid similar issues in the future.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions