Reputation: 11
When I want to use add-migration on .Net core I receive this error
PM> add-migration AuthenticationDB
Build started...
Build succeeded.
Could not load assembly ''. Ensure it is referenced by the startup project ''.
What does the error message mean? How I can fix it?
This my project .csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="3.1.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.9" />
</ItemGroup>
Upvotes: 1
Views: 3681
Reputation: 6894
If you only have one project in your solution, make sure that your Package Manager Console has the repository project selected in the drop down at the top.
If you have multiple projects in your solution then you need to reference a UI project (web. console, winforms etc) using the -s
flag and a reference to your repository project with the -p
flag.
For example;
Add-Migration MyMigrationMessage -s MySolution.MyWebProject -p MySolution.MyDataProject
Upvotes: 4