dotnet ef migrations add has a -o parameter this is not present in dotnet ef migrations remove
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 -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
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
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.
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.
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 '
if i try to use the dotnet ef --s
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.