Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet ef migrations add has a -o parameter this is not present in dotnet ef migrations remove #7780

Closed
viksabnis opened this issue Mar 3, 2017 · 9 comments
Labels
closed-no-further-action The issue is closed and no further action is planned.

Comments

@viksabnis
Copy link

dotnet ef migrations add --help
Project ADS.SwarmWebApi (.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation.
Usage: ef.dll migrations add [arguments] [options]
Arguments:
[name] The name of the migration
Options:
-h|--help Show help information
## -o|--output-dir The directory (and sub-namespace) to use. If omitted, "Migrations" is used. Relative paths are relative the directory in which the command is executed.
-c|--context The DbContext to use. If omitted, the default DbContext is used
--json Use json output. JSON is wrapped by '//BEGIN' and '//END'
--verbose Show verbose output
--assembly The assembly file to load.
--startup-assembly The assembly file containing the startup class.
--data-dir

The folder used as the data directory (defaults to current working directory).
--project-dir The folder used as the project directory (defaults to current working directory).
--content-root-path The folder used as the content root path for the application (defaults to application base directory).
--root-namespace The root namespace of the target project (defaults to the project assembly name).
-e|--environment The environment to use. If omitted, "Development" is used.

The -o|--output-dir is missing in dotnet ef migrations remove

dotnet ef migrations remove --help
Project ADS.SwarmWebApi (.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation.
Usage: ef.dll migrations remove [options]
Options:
-h|--help Show help information
-c|--context The DbContext to use. If omitted, the default DbContext is used
-f|--force Removes the last migration without checking the database. If the last migration has been applied to the database, you will need to manually reverse the changes it made.
--json Use json output. JSON is wrapped by '//BEGIN' and '//END'
--verbose Show verbose output
--assembly The assembly file to load.
--startup-assembly The assembly file containing the startup class.
--data-dir

The folder used as the data directory (defaults to current working directory).
--project-dir The folder used as the project directory (defaults to current working directory).
--content-root-path The folder used as the content root path for the application (defaults to application base directory).
--root-namespace The root namespace of the target project (defaults to the project assembly name).
-e|--environment The environment to use. If omitted, "Development" is used.

I want to create an assembly which contains only for my migrations - so that the migrations classes arent included in my runtime.

The --output-dir flag lets me create the migrations in a separate folder --- but now i have no way to remove a migration once added

@smitpatel
Copy link
Member

smitpatel commented Mar 3, 2017

dotnet ef migrations remove let you remove the last migration applied for given context (if there are multiple). You shouldn't need to specify a folder for that.
For adding migrations -o flag tells where to put new migration files since we are generating new files. Remove doesn't generate files hence doesn't have the flag.

@bricelam
Copy link
Contributor

bricelam commented Mar 3, 2017

but now i have no way to remove a migration once added

If you move the migration classes to a separate project, you should then execute the dotnet ef command on that project for migraitons operations.

@viksabnis
Copy link
Author

viksabnis commented Mar 3, 2017

there is no way to execute the dotnet ef command on that project - when i did i got this error message

Could not invoke this command on the startup project ' '. This version of the Entity Framework Core .NET Command Line Tools does not support commands on class library projects in ASP.NET Core and .NET Core applications. See http://go.microsoft.com/fwlink/?LinkId=798221 for details and workarounds.


if i try to use the dotnet ef --s migrations add/remove - but since the startup project no longer needs the migrations assembly dependency - it is unable to find the current assembly in the startup projects binaries

@obelixA
Copy link

obelixA commented Mar 4, 2017

what's even more, if you use the -o parameter to push the migrations into a separate folder neither the C# "database.migrate()" command nor the nuget console command "update-database" can find the migrations anymore. So there is missing something....

tested around and found that's not true for all cases. only if you push existing migrations into a separate folder. those are not found anymore. even not if renaming the folder back to "Migrations"...

ok. it took me now several hours to figure out - it seems like the namespace also has to be changed to reflect the new folder name. correct me if I'm wrong, but now it works again WITH separate folders per context...

@bricelam
Copy link
Contributor

bricelam commented Mar 7, 2017

Well, it should be possible to reference the migrations assembly from the startup project only at build time (i.e. it won't get published to the server) using the following.

<ProjectReference Include="..\MyApp.Migrations\MyApp.Migrations.csproj"
                  PrivateAssets="All" />

But it doesn't appear to work, so I've filed dotnet/sdk#952.

@viksabnis
Copy link
Author

This means there is a circular dependency - as the Migrations Assembly needs to be dependent on the Startup Assembly for the DbContext (FYI this is a dotnet core project and we are using project.json till msbuild is mainlined)

@bricelam
Copy link
Contributor

bricelam commented Mar 7, 2017

@obelixA I've created a sample that uses multiple assemblies with migrations in bricelam/Sample-SplitMigrations.

I'm going to close this issue for now, but let me know if you need any additional help getting this working.

@bricelam bricelam closed this as completed Mar 7, 2017
@bricelam bricelam added closed-no-further-action The issue is closed and no further action is planned. and removed type-investigation labels Mar 7, 2017
@bricelam bricelam removed this from the 2.0.0 milestone Mar 7, 2017
@bricelam bricelam removed their assignment Mar 7, 2017
@viksabnis
Copy link
Author

the sample given is for .net with csproj - this issue is not resolved for dotnet core usage with projectjson

@bricelam
Copy link
Contributor

bricelam commented Mar 7, 2017

The .NET Core SDK RTMed today. We are encouraging everyone doing .NET Core development to move to Visual Studio 2017, including migrating from project.json to csproj. We will not be supporting csproj and MSBuild for .NET Core in Visual Studio 2015.

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-no-further-action The issue is closed and no further action is planned.
Projects
None yet
Development

No branches or pull requests

5 participants