I am developing with Entity Framework code first and SQL Server 2008.
I want to support this common installation scenario:
- Database administrator manually creates a new database and a new user that has access only to that database (
database_owner
permission) - My application is configured with those database details and the new user's login
- My application uses Entity Framework to automatically initialize the database (create the tables, views, etc)
However, when I try to get Entity Framework to initialize the database:
context.Database.Create();
I will get an exception, because this method tries to create the database, not just create the tables, views, etc inside the database.
How can I get Entity Framework to initialize a database with a user that does not have "create database" permissions, using a database that has already been created for it?