AlisterKB
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
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
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