locked
Create Database Permission denied in Database Master RRS feed

  • Question

  • User438705957 posted

    I am using Visual Studio 2017.
    I have a solution with 2 projects. One for controllers/custom code etc and one for the Entity Framework Models and Context etc.
    The start-project has a reference added to it for the EF model project.
    The type of project is code-first EF that has been working well while running under IIS Express in VS.
    I have been using a localdb version of Sql Server Express.

    I decided to change the project to run under Local IIS so I could connect to it remotely.
    On running the project VS immediately informed me that I should be using SQL Server Express instead of localdb.
    So I downloaded SQL Server Express 2014 and installed it.

    I am running the project under integrated security with the following connection string:

        <add name="CACS_GNS_DataContext" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=Comm_CACS_GNS;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
    

    In SSMS, I have set the permissions for my network login under the SQL Express instance to have server roles of public, dbCreator and sysadmin.
    I expect EF to create the database and tables on first running based on the models.

    On every occasion VS is posting the error "Create Database permission denied in Database Master'.

    My network login has dbOwner role in that database, as well as all the other system databases.

    Thanks for considering


    Thursday, August 22, 2019 12:25 AM

Answers

  • User438705957 posted

    Thanks Yang Shen.

    I had previously found and followed those threads and am sure I have set the permissions correctly.
    I have logged in to SSMS under the 'sa' account, flagged dbcreator under 'server roles' for my network account, logged out and back in, and the permissions have stuck.

    I have since set the connection string for my context to be the 'sa' account and it works.
    I have reset it back to my network account, and changes I make to the model are reflected in the database.

    So it's still a mystery to me why I couldn't create the database under my network account in the first place.

    I thinks its related to having multiple projects in the solutions.

    In any case, I have got past the hurdle, until next time.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 22, 2019 3:35 AM

All replies

  • User-719153870 posted

    Hi Madog,

    In SSMS, I have set the permissions for my network login under the SQL Express instance to have server roles of public, dbCreator and sysadmin.

    Even after you checked these three permissions you still can't create database, my guess is that you are not "dbCreator " role.

    If you have already read this thread and followed the steps ,please refer to here to be a member of dbcreator server role.

    Also another thread is related that might help you.

    Best Regard,

    Yang Shen

    Thursday, August 22, 2019 2:30 AM
  • User438705957 posted

    Thanks Yang Shen.

    I had previously found and followed those threads and am sure I have set the permissions correctly.
    I have logged in to SSMS under the 'sa' account, flagged dbcreator under 'server roles' for my network account, logged out and back in, and the permissions have stuck.

    I have since set the connection string for my context to be the 'sa' account and it works.
    I have reset it back to my network account, and changes I make to the model are reflected in the database.

    So it's still a mystery to me why I couldn't create the database under my network account in the first place.

    I thinks its related to having multiple projects in the solutions.

    In any case, I have got past the hurdle, until next time.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 22, 2019 3:35 AM
  • User-719153870 posted

    Hi Madog,

    I have logged in to SSMS under the 'sa' account, flagged dbcreator under 'server roles' for my network account, logged out and back in, and the permissions have stuck.

    I have since set the connection string for my context to be the 'sa' account and it works.
    I have reset it back to my network account, and changes I make to the model are reflected in the database.

    This is a confusing situation, according to your description, your account has the role dbcreator but still can't create a database.

    Please try also add your account the role "sysadmin" which has the highest level authority.

    Also, please check if you can create a database with your network account in SSMS.

    Best Regard,

    Yang Shen

    Thursday, August 22, 2019 8:49 AM
  • User438705957 posted

    Yes Yang Shen, I had already added the "sysadmin" role to my network login, but was still getting the same problem.

    I would past a screenshot of it, but I can't see how to do this in the forum editor.

    Thanks

    Thursday, August 22, 2019 11:49 PM