.

Solved – Cannot attach the file ‘xxx.mdf’ as database ‘yyy’.

Getting this error:

Cannot attach the file ‘xxx.mdf’ as database ‘yyy’.

This can happen when you delete an EF database manually and it remains registered.

Solution:

Simply stop and delete your localdb – by running the following 2 commands in package manager (Tools – > Library Package Manager -> Package Manager Console)

sqllocaldb.exe stop v11.0
sqllocaldb.exe delete v11.0

and recreate the database if necessery (code-first):

Update-Database

What's your thoughts on this?

*

Protected by WP Anti Spam