Unable to generate an explicit migration in entity framework

后端 未结 28 1452
情书的邮戳
情书的邮戳 2020-12-12 23:31

I am adding a new migration but this message shows:

Unable to generate an explicit migration because the following explicit migrations are pending:

28条回答
  •  既然无缘
    2020-12-13 00:05

    1. Connection String / Connection Permissions

    Check the connection string again.

    Make sure the user you are connecting with still has permission to read from [__MigrationHistory] and has permission to edit the schema.

    You can also try changing the connection string in the App or Web config file to use Integrated Security (Windows Auth) to run the add-migration command as yourself.

    For example:

    connectionString="data source=server;initial catalog=db;persist security info=True;Integrated Security=SSPI;" 
    

    This connection string would go in the App.config file of the project where the DbContext is located.

    2. StartUp Project

    You can specify the StartUp project on the command line or you can right click the project with the DbContext, Configuration and Migrations folder and select Set as StartUp project. I'm serious, this can actually help.

提交回复
热议问题