ASP.NET MVC4 Code First - 'Cannot attach the file as database' exception

后端 未结 4 908
独厮守ぢ
独厮守ぢ 2020-12-21 03:58

I\'m using Code First concept in Entity Framework and I\'m constantly getting the following exception while starting application:

Cannot attach the file \'C:         


        
4条回答
  •  一向
    一向 (楼主)
    2020-12-21 04:15

    I found the solution. With newest SQL Server Management studio there is no problem in connecting to the local database. Connection needs to be established like this:

    enter image description here

    After logging in we can still see old database present even if there is nothing under App_Data directory and under Data Connections in Server Explorer in Visual Studio. When we delete that database from SQL Server Management studio and start application again there will be no more errors while attaching database.

提交回复
热议问题