Search code examples
postgresqlasp.net-core-2.1entity-framework-core-2.1

.net core entity framework create tables inside existing database


I don't want to give my sql user the permissions to create databases.

Is there any way to create the database manually and then have entity framework create the tables inside it?


Solution

  • I'm certain EF Core is smart enough to handle this case. Just create the database, set your permissions and run the command dotnet ef update-database (assuming you have a valid migration).

    Usually, an application (or multiple applications) use the same database from separate DbContext classes, which handle their own bounded context (a logical piece of the whole). That would require being able to recognize that Databases and Tables have already been created, and issue appropriate add and alter commands to the schema.