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

Snapshot location uisng Add-Migration -OutputDir with Release fodler #13342

Closed
generik0 opened this issue Sep 17, 2018 · 7 comments · Fixed by #22217
Closed

Snapshot location uisng Add-Migration -OutputDir with Release fodler #13342

generik0 opened this issue Sep 17, 2018 · 7 comments · Fixed by #22217
Assignees
Labels
area-migrations closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported punted-for-3.0 punted-for-3.1 type-bug
Milestone

Comments

@generik0
Copy link

HI

Thanks for a cool package.
When i for a migration i like to use:

Add-Migration -OutputDir Migrations\Release2018_x -Context XzyMigrationDbContext -Project Xzy.Migrations -StartupProject Xzy.App -Name Add_Xxy

But this also means that the snapshot is in the Migrations\Release2018_x folder.
What do i do when i make the next release and the migrations shoud be in Migrations\Release2019_y release.
Will there be issues with the multiple shnapshots=?

Thanks again, Br Rik

@bricelam
Copy link
Contributor

Feel free to move the file and change the namespace. The tool can usually find it and update it.

Don't add two snapshots. That will cause problems.

@generik0
Copy link
Author

@bricelam
Thanks for your answer, i find that if i move, it creates a new one each time under the Migrations\Release2018x.

I have tried to move to root, i.e "Migrations" and then an add-migration just creates a new snapshot.

@ajcvickers
Copy link
Member

@generik0 Can you please post a runnable project/solution that demonstrates the behavior you are seeing?

@generik0
Copy link
Author

generik0 commented Sep 20, 2018

@ajcvickers

I think you guys can make this test yourselves. It shold be a part of you CI integration tests.
Please note, i do not believe i saw this behaviour on 2.1.1, only 2.1.2
Please note that the migrations are moved into a fodler as VS is not making design dependant on main cs.
Please note snapshot is moved to folder parent to ouptut dir.

Snapshot under release folder:
image

Snampshot moved and namespace changed:
image

Migrations run with Add-Migration -OutputDir Migrations\Release2018_Q2 -Context ContentMigrationDbContext -Project Migration -StartupProject Web.App -Name TestSnapshot

image

@generik0
Copy link
Author

generik0 commented Oct 5, 2018

@ajcvickers I have made an example. You just need to run:
Add-Migration -outputdir Migrations/Release42 -Context TestDbContext -project EfCoreMultipleTransactionsSameDbContext -startupproject EfCoreMultipleTransactionsSameDbContext -Name Add_Test
And you will see there is an extra snapshot created.
EfCoreNewSnapshotCreated.zip

@ajcvickers
Copy link
Member

@generik0 Yes, thank you. I was able to reproduce this previously, hence it is assigned as a bug and in a milestone.

@jasonliaocn
Copy link

jasonliaocn commented Nov 1, 2018

Hi, is it possible to create multiple target? previously my database is SQL server and I already have some migration histories, now I may want to deploy it to MySQL but all I can do is to delete the SQL Server migrations folder and start from the beginning again.

if I can specify the output folder for example Migrations-MySQL and there will be a new ModelSnapShot for MySQL generated would be better.

so the structure could be:
Migrations
---MySQL
------20181101042215_Add_Test.cs
------20181101042215_Add_Test.Designer.cs
------TestDbContextModelSnapshot.cs
---SQLServer
------20181101042215_Add_Test.cs
------20181101042215_Add_Test.Designer.cs
------TestDbContextModelSnapshot.cs

then I can specify to UseSqlServer or UseMySql with the target Migrations.

@divega divega modified the milestones: 3.0.0, Backlog Jun 20, 2019
@bricelam bricelam modified the milestones: Backlog, 3.1.0 Aug 21, 2019
@ajcvickers ajcvickers modified the milestones: 3.1.0, Backlog Oct 11, 2019
@bricelam bricelam modified the milestones: Backlog, 5.0.0 Nov 5, 2019
bricelam added a commit to bricelam/efcore that referenced this issue Aug 25, 2020
…ation

Note, --output-dir is still used to determine the directory on the first migration.

Fixes dotnet#13342
@bricelam bricelam added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Aug 25, 2020
@bricelam bricelam modified the milestones: 5.0.0, 5.0.0-rc1 Aug 25, 2020
@ajcvickers ajcvickers modified the milestones: 5.0.0-rc1, 5.0.0 Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-migrations closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported punted-for-3.0 punted-for-3.1 type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants