jasontaylordev / CleanArchitecture

Clean Architecture Solution Template for ASP.NET Core

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't create migrations

JohnyBro opened this issue · comments

Describe the bug
When I try to create a new migration I have the following error.

...\src\Infrastructure\Infrastructure.csproj : error MSB4057: The target "GetEFProjectMetadata" does not exist in the project.
Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project. If you're using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option.

To Reproduce
Steps to reproduce the behavior:

  1. Install the template
  2. Create a new project with only api
  3. Add a property to the TodoItem class
  4. Run dotnet ef migrations add "SampleMigration" --project src\Infrastructure --startup-project src\Web --output-dir Data\Migrations

Expected behavior
Add a migration to the Data/Migrations folder

This is caused by a bug in simplified output paths;

Work around this issue by updating Directory.Build.props and disabling simplified output paths:

<!-- See https://aka.ms/dotnet/msbuild/customize for more details on customizing your build -->
<Project>
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <!-- <ArtifactsPath>$(MSBuildThisFileDirectory)artifacts</ArtifactsPath> -->
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
</Project>

Thank you for your answer, all good now.