In EF Core, how do I insert new data to an existing DB with a Migration?
I want to create a migration to insert new data to an existing database deployed in multiple environments. In some environments, devs have already manually inserted the rows. What's the best way of handling this in EF core?
Creating a migration that just runs raw insert SQL scripts? And in the raw SQL, check for existence?
6 Replies
raw sql and maybe consider a
MERGE
statement?If there’s no existing data, should I still raw sql insert it?
MERGE
covers both casesare merge statements the standard way of inserting/updating data in migrations?
idk about standards, but
MERGE
covers the "if exists do x, if not do y" use caseyeah I’ll use merge statements, ty!
if anyone else can chime in on standard methodology that’d be great too