Skip to content

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Feb 16, 2024

Fixes #398

Improves Aspire + EF migrations:

  1. Centralized connection string validation in a shared file. The same code and message were duplicated everywhere.
  2. Updated connection string validation for Aspire EF database components to be skipped if EF.IsDesignTime is true.
  3. Adds a migration focus project to solution. Is configured to apply EF migrations in a project that starts with the host. The readme.md explains how to use it.
Microsoft Reviewers: Open in CodeFlow

@JamesNK JamesNK added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Feb 16, 2024
@JamesNK JamesNK force-pushed the jamesnk/databasemirgration branch 2 times, most recently from d60a5db to 47ddae3 Compare February 16, 2024 14:33
@JamesNK
Copy link
Member Author

JamesNK commented Feb 16, 2024

@JamesNK JamesNK force-pushed the jamesnk/databasemirgration branch from 47ddae3 to 1a030e1 Compare February 17, 2024 04:40
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<PropertyGroup>
<!-- Clear solution default because EF tooling doesn't like a custom value. -->
Copy link
Member

@mitchdenny mitchdenny Feb 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you file a bug with EF for this and add a link to it in an XML comment?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's tracked by dotnet/efcore#23853

@mitchdenny
Copy link
Member

This looks like a workable solution to me. Good stuff!

<MicrosoftExtensionsDiagnosticsHealthChecksPackageVersion>8.0.2</MicrosoftExtensionsDiagnosticsHealthChecksPackageVersion>
<MicrosoftExtensionsFeaturesPackageVersion>8.0.2</MicrosoftExtensionsFeaturesPackageVersion>
<MicrosoftEntityFrameworkCoreCosmosPackageVersion>8.0.2</MicrosoftEntityFrameworkCoreCosmosPackageVersion>
<MicrosoftEntityFrameworkCoreDesignPackageVersion>8.0.2</MicrosoftEntityFrameworkCoreDesignPackageVersion>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need a Version.Details.xml entry?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. I'm not familiar with when it needs to be updated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +5 to +9
<PropertyGroup>
<!-- Clear solution default because EF tooling doesn't like a custom output path. -->
<!-- Issue: https://github.com/dotnet/efcore/issues/23853 -->
<BaseIntermediateOutputPath></BaseIntermediateOutputPath>
</PropertyGroup>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just do this in a Directory.Build.props in the playground\DatabaseMigration folder instead of having this duplicated across all the new projects?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried doing that, but it introduced a new problem with the Aspire project not able to find its props/targets.

BaseIntermediateOutputPath change only needs to be done inside the database migration example.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it introduced a new problem with the Aspire project not able to find its props/targets.

I don't understand what this means. Can you elaborate?

BaseIntermediateOutputPath change only needs to be done inside the database migration example.

Right, that's why I suggest adding it to the playground\DatabaseMigration folder.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it works #2327 🤷

@eerhardt eerhardt mentioned this pull request Feb 20, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Postgres/SQL Server EF components make it hard to run dotnet ef to create migrations, etc.
5 participants