AlisterKB
AlisterKB
CC#
Created by AlisterKB on 4/17/2025 in #help
creating migrations on an existing DB to add a column(efcore)
@Optimum firstly, thanks for entertaining my question and providing the link. @TeBeCo afer trying the workaround to no avail, I have come to the conclusion that -ignorechanges is not available for efcore and was a feature of ef6 so my question is what is the right way to deal with a code base you have started with an existing DB? I would assume one has no choice but to scaffold. but would it make sense to add an empty migration (manually removing everything ) so you would have a starting for your future migration without nuking the DB ? or should I just keep changing the db through queries and keep scaffolding. also I believe going code first with migrations add a migration table to the DB where it keeps track of implemented migrations ? (i might be wrong never done code first before as I mentioned earlier) would adding empty migrations in the middle of a scaffolded project also add migration history table to the DB (if it adds a migration history table to begin with)
31 replies
CC#
Created by AlisterKB on 4/17/2025 in #help
creating migrations on an existing DB to add a column(efcore)
reading it now
31 replies
CC#
Created by AlisterKB on 4/17/2025 in #help
creating migrations on an existing DB to add a column(efcore)
so just for sake of testing I created an instance of my db locally. then I also went to to a new branch in my repo I careted a migration and anually change up and dodwn just to update the column protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn<decimal>( name: "AmountInOriginalUnit", table: "payment", type: "numeric", nullable: true, defaultValue: 0.00m); // Safe default for decimal type } /// <inheritdoc /> protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropColumn( name: "AmountInOriginalUnit", table: "payment"); } and it worked would this be a disaster of a workaround? also if I have scaffolded should I immediately add a migration to avoid the hell im ar right now or what is the way to prevent this if I start dbfirst ?
31 replies
CC#
Created by AlisterKB on 4/17/2025 in #help
creating migrations on an existing DB to add a column(efcore)
I do not, since the beginning of the project I just scaffolded and that's it
31 replies
CC#
Created by AlisterKB on 4/7/2025 in #help
Hangfire implementation in Repository pattern
Are you referring to AddOrUpdate method? To be honest i simply followed tht convention because the method provided by hangfire to add recurring job is recurringjob.AddOrUpdate(). Granted I'm hardly familiar with hangfire and have been only playing with it for couple of days. I'll dig around and see if they have a separate method for each of the tasks and update them to ve SRP compliant. Regardless, thanks a bunch!
8 replies
CC#
Created by AlisterKB on 4/7/2025 in #help
Hangfire implementation in Repository pattern
@Thalnos i truly appreciate your concise and yet thorough reply. And thank you for clarification on aggregate. I had the wrong idea of it 🙏 🙏
8 replies
CC#
Created by AlisterKB on 2/16/2025 in #help
casting required for nullable even after checking for null
I see! reading about it and checking the link. thanks a lot for opening my eyes to better practices, really appreciate it!
15 replies
CC#
Created by AlisterKB on 2/16/2025 in #help
casting required for nullable even after checking for null
what do I use then ? 🙂
15 replies
CC#
Created by AlisterKB on 2/16/2025 in #help
casting required for nullable even after checking for null
thank you legends!
15 replies