jasontaylordev / CleanArchitecture

Clean Architecture Solution Template for ASP.NET Core
MIT License
16.75k stars 3.6k forks source link

Can't create migrations #1137

Closed JohnyBro closed 7 months ago

JohnyBro commented 7 months ago

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

jasontaylordev commented 7 months ago

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>
JohnyBro commented 7 months ago

Thank you for your answer, all good now.