.NET Developer Interview Question

How do you manage EF Core migrations across environments and in production?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Generate migrations in development, review the generated code and SQL like any other change, and commit them. For production, produce an idempotent SQL script or a migration bundle in the pipeline and apply it as a deliberate deployment step, rather than calling Migrate at application startup. Keep each change backwards compatible so old and new code can run together, and split breaking changes such as renames into expand and contract steps.

Why interviewers ask this

Schema changes are where deployments most often go wrong, and EF Core makes it dangerously easy to apply them automatically at startup. The interviewer wants to see that you review generated migrations, apply them as a controlled step with appropriate permissions, and design changes so a rolling deployment does not break. Spotting that a rename can be generated as a drop and an add, losing data, shows real experience.

How to structure your answer

  • Describe how migrations are created, reviewed and committed.
  • Explain how you apply them in production, and why not at startup.
  • Cover backwards compatible changes and expand and contract.
  • Mention data backfills and rollback planning.

Example answer

Spoken example, first person

Migrations are created in development and reviewed in the pull request, including the SQL they produce, because the generator occasionally does something you would not choose. The classic case is a renamed property scripted as drop column and add column, which deletes the data. For production I do not call Migrate at startup. With several instances starting at once they can race each other, and the app's database account would need rights to alter the schema. Instead the pipeline produces an idempotent script or a migration bundle, and a deployment step applies it with a dedicated account before the new code rolls out. The other rule is that every migration must work with both the old and new versions of the code, because during a rolling deployment both are running. So a rename becomes add the new column, write to both, backfill, switch reads, and drop the old column in a later release. Large backfills run as a separate batched job, not inside the migration, so they do not lock a busy table.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • How would you roll back a migration that has already run in production?
  • How do you handle a migration on a table with hundreds of millions of rows?
  • What do you do when two developers create migrations on separate branches?

Related .net developer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot