简体   繁体   中英

How can I connect to a database in Visual Studio

How can I connect to a database in Visual Studio with Entity Framework?

I have a database:

在此处输入图片说明

But in visual studio I don't know what I must enter.

I have a window:

在此处输入图片说明

Can You say what I must write there? I tried many times and I still have error.

You can choose the instance name when you install SQLServer Enterprise or SQLServer Express. I think it is the same for other database.

In the other hand, you can add a new database just in Visual studio project. Then you will get a MDF file in the resources list, which can be added here.

I don't know if I understood you, but those fields are about the server where the database is

Server name is the name o the server that appears on SQL Managment Studio (probably the name of the machine the server is running on)

When you open SQL Server Management studio you can a popup as shown below:

在此处输入图片说明

The server name that you use there should be the one you can use in your case. If the SQL Server database is installed on your machine it would be (local) or your machines name which can be found by right clicking on "My Computer" and then Properties and you can see "Computer Name" in the window that opens.

A dot (aka period), like this: .

If you have SQL Server Express installed, it should be .\\sqlexpress

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM