【发布时间】:2023-01-30 21:34:52
【问题描述】:
我正在使用 dotnet ef dbcontext scaffold 命令创建我的数据库上下文。自从将工具链更新到 v7.0.2 后,我在输出中收到此警告:
Build started...
Build succeeded.
The database user has not been granted 'VIEW DEFINITION' rights. Scaffolding requires these rights to construct the Entity Framework model correctly. Without these rights, parts of the scaffolded model may be missing, resulting in incorrect interactions between Entity Framework and the database at runtime.
数据库用户在db_owner角色中,但另外我已经针对Master数据库手动执行
grant view any definition to [dbusername]
警告消息仍然存在。有人可以帮忙吗?
【问题讨论】:
-
db_owner角色成员身份应该足够了,除非权限被明确拒绝。当以 dbusername 登录时,尝试通过在用户数据库的上下文中运行SELECT HAS_PERMS_BY_NAME(NULL,NULL,'VIEW ANY DEFINITION');来验证权限。
标签: sql-server .net-core entity-framework-core