You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/data-tools/create-a-sql-database-by-using-a-designer.md
+11-17Lines changed: 11 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -18,20 +18,14 @@ manager: ghogen
18
18
ms.technology: "vs-data-tools"
19
19
---
20
20
# Create a database and add tables in Visual Studio
21
-
You can use Visual Studio to create and update a local database file in SQL Server Express LocalDB. You can also create a database by executing Transact-SQL statements in the **SQL Server Object Explorer** tool window in Visual Studio. In this topic, we'll explore the following tasks:
22
-
23
-
-[Create a project and a local database file](../data-tools/create-a-sql-database-by-using-a-designer.md#BKMK_CreateNewSQLDB)
24
-
25
-
-[Create tables, columns, primary keys, and foreign keys](../data-tools/create-a-sql-database-by-using-a-designer.md#BKMK_CreateNewTbls)
26
-
27
-
-[Populate the tables with data](../data-tools/create-a-sql-database-by-using-a-designer.md#BKMK_Populating)
21
+
You can use Visual Studio to create and update a local database file in SQL Server Express LocalDB. You can also create a database by executing Transact-SQL statements in the **SQL Server Object Explorer** tool window in Visual Studio. In this topic, we'll create an .mdf file and add tables and keys by using the Table Designer.
28
22
29
23
## Prerequisites
30
24
To complete this walkthrough, you must have the optional **Data storage and processing** workload installed in Visual Studio. To install it, open **Visual Studio Installer** and choose the **Workloads** tab. Under **Web & Cloud**, choose **Data storage and processing**. Choose the **Modify** button to add the workload to Visual Studio.
31
25
32
-
## <aname="BKMK_CreateNewSQLDB"></a> Create a project and a local database file
26
+
## Create a project and a local database file
33
27
34
-
####To create a project and a database file
28
+
### To create a project and a database file
35
29
1. Create a Windows Forms project that's named `SampleDatabaseWalkthrough`.
36
30
37
31
2. On the menu bar, select **Project**, **Add New Item**.
@@ -42,7 +36,7 @@ To complete this walkthrough, you must have the optional **Data storage and proc
42
36
43
37
4. Name the database **SampleDatabase**, and then select the **Add** button.
44
38
45
-
####To add a data source
39
+
### To add a data source
46
40
5. If the **Data Sources** window isn't open, open it by selecting the **Shift+Alt+D** keys or, on the menu bar, selecting **View**, **Other Windows**, **Data Sources**.
47
41
48
42
6. In the **Data Sources** window, select the **Add New Data Source** link.
@@ -59,17 +53,17 @@ To complete this walkthrough, you must have the optional **Data storage and proc
59
53
60
54
11. One the **Choose your Database Objects** page, you'll see a message that says the database doesn't contain any objects. Choose **Finish**.
61
55
62
-
####To view properties of the data connection
56
+
### To view properties of the data connection
63
57
You can view the connection string for the SampleDatabase.mdf file by opening the properties window of the data connection:
64
58
65
59
- In Visual Studio, select **View**, **SQL Server Object Explorer** if that window isn't already open. Open the properties window by expanding the **Data Connections** node, opening the shortcut menu for SampleDatabase.mdf, and then selecting **Properties**.
66
60
67
61
- Alternatively, you can select **View**, **Server Explorer**, if that window isn't already open. Open the properties window by expanding the **Data Connections** node. Open the shortcut menu for SampleDatabase.mdf, and then select **Properties**.
68
62
69
-
## <aname="BKMK_CreateNewTbls"></a> Create tables, columns, primary keys, and foreign keys
63
+
## Create tables and keys by using Table Designer
70
64
In this section, you'll create two tables, a primary key in each table, and a few rows of sample data. You'll also create a foreign key to specify how records in one table correspond to records in the other table.
71
65
72
-
####To create the Customers table using Table Designer
66
+
### To create the Customers table
73
67
1. In **Server Explorer** or **SQL Server Object Explorer**, expand the **Data Connections** node, and then expand the **SampleDatabase.mdf** node.
74
68
75
69
2. Open the shortcut menu for **Tables**, and then select **Add New Table**.
@@ -105,7 +99,7 @@ In this section, you'll create two tables, a primary key in each table, and a fe
105
99
106
100
Your changes are saved to the local database file.
107
101
108
-
#### To create the Orders table
102
+
### To create the Orders table
109
103
1. Add another table, and then add a row for each entry in the following table:
110
104
111
105
|Column name|Data type|Allow nulls|
@@ -129,7 +123,7 @@ In this section, you'll create two tables, a primary key in each table, and a fe
129
123
130
124
Your changes are saved to the local database file.
131
125
132
-
#### To create a foreign key
126
+
### To create a foreign key
133
127
1. In the context pane on the right side of the grid, open the shortcut menu for **Foreign Keys**, and then select **Add New Foreign Key**, as the following illustration shows.
134
128
135
129

@@ -148,9 +142,9 @@ In this section, you'll create two tables, a primary key in each table, and a fe
148
142
149
143
Your changes are saved to the local database file.
150
144
151
-
## <a name="BKMK_Populating"></a> Populate the tables with data
145
+
## Populate the tables with data
152
146
153
-
#### To populate the tables with data
147
+
### To populate the tables with data
154
148
155
149
1. In **Server Explorer** or **SQL Server Object Explorer**, expand the node for the sample database.
0 commit comments