-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Comments
|
If you move the migration classes to a separate project, you should then execute the |
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 |
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... |
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. |
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) |
@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. |
the sample given is for .net with csproj - this issue is not resolved for dotnet core usage with projectjson |
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. |
dotnet ef migrations add --help
The folder used as the data directory (defaults to current working directory).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
--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
The folder used as the data directory (defaults to current working directory).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
--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
The text was updated successfully, but these errors were encountered: