entityframeworktutorial / EF6-DBFirst-Demo

Entity Framework 6 Database-First Demo Project
MIT License
143 stars 159 forks source link

Cannot Attach SchoolDB.mdf to localdb #9

Open johncblacker opened 11 months ago

johncblacker commented 11 months ago

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 commented 11 months ago

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