dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.69k stars 3.17k forks source link

Cleanup output-path behavior when generating migrations #32738

Open ajcvickers opened 9 months ago

ajcvickers commented 9 months ago

Adding a new, initial migration "M" results in three new files:

However, using --output-path changes this in non-obvious ways. There are four subcategories:

Relative output path

This is presumably the intended use, and the results seem reasonable:

Empty output path

Note that this is not the same as a null output path, and is not blocked. Presumably, it should mean either the same as null or it should mean don't use Migrations, which is the default, and instead just put the files directly in the project root. We actually do half and half:

Notice that the snapshot still goes into "Migrations", but the other files go in the project root.

Absolute output path

It's not clear to me that this was ever intentional, but it is not blocked. I assume people will do this because they want to explicitly place the files somewhere outside the project.

Given the absolute output path /mydrive, the files generated are:

Notice that snapshot file is not in the output path (it's still relative to the project) and is in the "Migrations" folder.

Output path and namespace set

When the --namespace option is also used, then it impacts some paths but not others. For example, with --namespace Acme.Packing --output-dir outputDir:

Notice that the snapshot goes into a folder named for the namespace, but the other files go into the output path.

FYI, the result of using namespace without output-path is:

ajcvickers commented 9 months ago

Notes from design meeting:

In general, we will honor output-path, including for the snapshot file.

Empty output path

Absolute output path

Output path and namespace set

joakimriedel commented 8 months ago

also see #32752 which was confusing to me regarding output path