Documentation is missing information on how to set up database users and rights
See original GitHub issueSetting up a fresh database installation (using Entity Framework Core EnsureCreated()
), I need to create a number of database users and grant appropriate rights to them for all objects that ModelBuilder
is creating (e.g. entities, sequences etc., but also user permissions, like CREATE SESSION
system privilege).
My goal is to end up with a single DBA user for later database migration and a less privileged application user for running the app.
I’ve been looking for corresponding ModelBuilder
extension methods, but couldn’t find any.
As far as I can see, documentation lacks information on how to create database users and grant privileges using EF Core Code-first.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 1b15cd4c-9cba-c0e2-7618-7d621a3c5936
- Version Independent ID: f4681bc6-57be-6e69-cad9-776ce64d93bd
- Content: Overview of Entity Framework Core - EF Core
- Content Source: entity-framework/core/index.md
- Product: entity-framework
- Technology: entity-framework-core
- GitHub Login: @ajcvickers
- Microsoft Alias: avickers
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
This is the crux of the matter - and unfortunately it simply doesn’t seem to be true; while at a superficial glance, databases indeed have users and users can be granted privileges, when looking deeper there are some important differences.
As an example, compare SQL Server CREATE USER, PostgreSQL CREATE USER and Oracle CREATE USER. The various options are quite different, since the database capabilities around user, role and privilege management are different; that’s the unfortunate reality of world of databases. In contrast, SQL query syntax and behavior are better standardized and generally tend to be similar across databases (although with important exceptions).
To summarize:
I understand this isn’t a perfect experience, but that seems quite orthogonal to the issue being discussed above. If you need to manage users and privileges, these need to be specified in any case - the question in this issue is whether that’s done in raw SQL or via an EF API.
Triage decision: this isn’t something we plan to implement in EF Core - there’s not enough common ground across databases, and the value is generally limited given that raw SQL can be used (and given the investment required).
Of course, something may be doable in a nuget package, although unlike EFCore.CheckConstraints, support for this would probably need to interact with other parts of EF Core which aren’t necessarily easily extensible to plugins (e.g. the migrations SQL provider).