Cannot attach the file *.mdf as database

后端 未结 22 1910
猫巷女王i
猫巷女王i 2020-11-27 14:22

Basically I\'ve followed a tutorial and decided to delete the .mdf file afterwards.

Now whenever I try to run the application I get the following error

22条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-27 14:36

    I recently ran into the same problem. Here is one thing to check. in visual studio there are three place we should check and remove the database.

    1. Solution Explorer's App_Data folder
    2. Server Explorer's Data Connection menu
    3. SQL Server Object Explorer
    

    When I delete database from the first two point, the error still occurs. So, I needed to delete the database from the SQL Server Object Explorer as well. Then I could easily run the 'update-database' command without error. Hope this helps.

提交回复
热议问题