C
C#19h ago
Faker

Is it possible to change Migrations folder path when updating database using UI tools for EF Core

Hello guys, when using the UI tools for migration in rider, normally, we look into the Migrations folder where our project is. For instance, if our .csproj is in Learning, we would look for Migrations sub-folder in Learning. My question is, can we change that to look inside Library/Migrations instead? The idea is, I wanted several folders to hold different dbContext Migrations. Like say one for School, one for Library etc. I was able to specify where my migrations go when I add to it, like Library/Migrations. BUT when I update database, it seems it still look into Migration folder in Learning and so it doesn't recognise/find any migration related to the one I want to process.
11 Replies
glhays
glhays19h ago
You might get some good pointers from this. https://code-maze.com/aspnetcore-multiple-databases-efcore/
Marinko Spasojević
Code Maze
Using Multiple Databases in ASP.NET Core via Entity Framework Core
In this article, we'll learn how to add multiple databases in the ASP.NET Core project using Entity Framework Core and Repository Pattern.
Unknown User
Unknown User18h ago
Message Not Public
Sign In & Join Server To View
Faker
FakerOP18h ago
Yep, I will just have a look, normally I just merge migrations of 2 different db context in a single folderz it works but just wanted to know if there was a better way because of the warning I got telling me that the migration folder contain more than 1 db context
Unknown User
Unknown User18h ago
Message Not Public
Sign In & Join Server To View
Faker
FakerOP18h ago
Hmm basically I'm not using ASP.Net so I guess the article may be out of scope The thing is, each dbcontext should be in a different csproj ? Like say we have 2 db, School and Library ?
Unknown User
Unknown User18h ago
Message Not Public
Sign In & Join Server To View
Faker
FakerOP18h ago
Yeahh tried that but when we use the update database it seems that it doesn't look in the output dir but a default Migration folder I will try again later on to see if it works
Unknown User
Unknown User18h ago
Message Not Public
Sign In & Join Server To View
Faker
FakerOP18h ago
Yeah, will try and come back and let you know
Unknown User
Unknown User18h ago
Message Not Public
Sign In & Join Server To View
Faker
FakerOP17h ago
Ok 👍 Yep it worked, thanks !

Did you find this page helpful?