I'm new to the Entity Framework and setting up a correct SQL Server.
I'm following the official Entity Framework tutorial and I'm at the "Creating the Database"-step about 30% down the page.
copy the School.mdf file from the following folder to your application's App_Data folder
Instead of using the School.mdf
file I'm using my own file that was automatically created by using SQL Server Management Studio (I downloaded that from the Microsoft Download Center, selecting the ENU\x86\SQLEXPRADV_x86_ENU.exe
option) to create a database with tables.
When in Visual studio 2010 Ultimate, I:
Go the Server Explorer
and right click on Data Connections
--> Add Connection
:
Choose the Microsoft SQL Server Database File
-option for Data source and press Continue
.
Click on Browse...
under Database file name
.
Select the file in the %PROGRAMFILES%\Microsoft SQL Server\MSSQL11.MOBILIZEMESQL\MSSQL\DATA
directory, since that's where it's saved.
Get the error.
Picture version:
1.
2.
3.
I get the error message:
DateBaseName.mdf
This file is in use.
Enter a new name or close the file that's open in another program.
Since the tutorial doesn't tell me directly how to do this I first figured my goal was to find a way to open .mdf
-files, and this was the one I could find.
I'm thinking I'm getting the error because the SQL Server is running (since the Management Studio isn't), since I don't know what else should be using the file.
I could copy the file into another directoy, but then wouldn't I have to update the file everytime I change the database?
Since I'm new to this, I know I'm missing something obvious here.
Is there a proper way of connecting a database to Entity Framework?