“Update-Database” command fails with TimeOut exception

后端 未结 4 1604
南旧
南旧 2021-02-18 19:37

I\'m using EF migrations and have a table with a lot of data. I need to change MaxLength of a concrete column (it hadn\'t length constraints).

ALTER TABLE MyDb A         


        
4条回答
  •  广开言路
    2021-02-18 20:19

    In my case the issue was caused by a very large query which timed out in EF but was able to complete in SSMS.

    The answer which suggests Update-Database -script did not work for me, it gave another error message.

    For me, I did the following:

    • Open SSMS
    • Tools > SQL Server Profiler
    • Go back to VS and run Update-Database
    • Watch the Server Profiler
    • You should be able to see the query it times out on
    • Copy that query and run it in SSMS
    • Now re-run Update-Database and that slower part should be fine because the query has already been completed.

    Disclaimer: This might not work for all cases, because it depends on what particular query is slowing you down. For me, it worked.

提交回复
热议问题