Entity framework code first migrations, sql user p

2020-05-27 03:55发布

What is the minimal permission needed on a sql server user/login for it to be able to run entity framework code first database migrations?

I naively would have thought that a user with the roles db_datareader, db_datawriter, Grant Alter on the Schema and Grant Create Table would be permissive enough.

2条回答
Emotional °昔
2楼-- · 2020-05-27 04:22

On-Prem: SQL server with AD/sql login

you need the following permissions on the database.

[db_datareader]
[db_datawriter]
[db_ddladmin]

For full control over database use

[db_owner]

Azure Could: Azure SQL with ADD (Edit)

Please add [dbmanager] to master and user database.

查看更多
看我几分像从前
3楼-- · 2020-05-27 04:23

Clearly it depends on what your migrations are/(will be) doing. For my use case, I ended up creating a shema, and restricting the user that the migration uses to the permissions below.

GRANT ALTER, INSERT, SELECT, DELETE, UPDATE, REFERENCES ON SCHEMA::schema_name TO migration_user
GRANT CREATE TABLE TO migration_user
查看更多
登录 后发表回答