Entity Framework Core - Database.Migration()

Viewed 161

I would like to ask you if it is possible to proceed (in entity framework core):

context.Database.Migrate();

using database user without ddladmin permissions?

What I would like to achieve:

User without permission should not update migrations (without errors). However users with those kinds of permissions should be able to make migrations.

Currently, I am getting this kind of errors:

System.Private.CoreLib: Exception while executing function: xxx. Core Microsoft SqlClient Data Provider: CREATE TABLE permission denied in database 'xxxx'.

1 Answers

You have two options:

  1. You give the user the db_ddladmin role

  2. You add the create table grant to the user, like GRANT CREATE TABLE TO Joe AS dbo

I think the second one is what you are looking for.

Related