EF6-DBFirst-Demo icon indicating copy to clipboard operation
EF6-DBFirst-Demo copied to clipboard

Cannot Attach SchoolDB.mdf to localdb

Open johncblacker opened this issue 1 year ago • 1 comments

I just started working with this sample (and, by the way, it appears to me to be one of the best sites for help with entity framework) and ran into the attach problem with the error message indicating it couldn't find the .ldf file. My solution, thanks to my daughter who happens to be ea DBA is to execute this code from within MS SQL Server Studio: sp_attach_db @dbname= N'SchoolDB'
, @filename1= N'C:\Users\jblac\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB\EF6-DBFirst-Demo\EF6DBFirstDemo\SchoolDB.mdf'

This was executed after right clicking on "New Query" in the toolbard, dropping the above code changed according to where you put the .mdf file and then selecting " Execute." This seems to me to be an easier solution than others that I looked at in the "closed issues" section and from searching online. I am using the pre-installed localdb (express) version running on windows 11.

johncblacker avatar Dec 22 '23 17:12 johncblacker

I suggest that the repository creator put my "fix" into the README as a step in getting started with the repository.

johncblacker avatar Dec 22 '23 17:12 johncblacker