How to use a different connection string (but same database) for migrations

前端 未结 1 1784
旧巷少年郎
旧巷少年郎 2020-12-21 04:17

I have been using a connection string like this to connect my website to my database:



        
相关标签:
1条回答
  • 2020-12-21 05:19

    I finally solved this by adding the website_staging_migrations user to the db_datareader and db_datawriter roles as well as the db_ddladmin role.

    The user obviously needs to read the data in the __MigrationHistory table. What threw me was that EF doesn't report the failure to access the table as an error and instead I got this error when it tried to run the initial migration:

    There is already an object named '----' in the database.
    

    And the user also needs to write to the __MigrationHistory table. I got this error until I added the user to the db_datawriter role:

    The INSERT permission was denied on the object '__MigrationHistory',
    database 'Staging', schema 'dbo'.
    
    0 讨论(0)
提交回复
热议问题