Database and user creation in EF Core when deploying to Kubernetes Database and user creation in EF Core when deploying to Kubernetes kubernetes kubernetes

Database and user creation in EF Core when deploying to Kubernetes


I've been tussling with this question as well. We're doing .NET Core EF code first on Kubernetes with a Microsoft SQL database.

I've been messing around with context.Database.Migrate(). This will create the DB then create the tables and do the migrations (case 1), or if the DB already exists, it will just create the tables and do the migrations (case 2).

For case 1, the account needs to have the dbcreator server role. Once it creates the DB, it will assign itself the dbo database role.

For case 2, you could potentially just give db_ddladmin, db_datareader, and db_datawriter. I've tested this and it seems to work fine, but I'm unsure of the side effects of not having dbo access. Julie?