Microsoft Visual Studio 2015

Creating SQL Server Database Tables

Visual Studio 2012 supports a new version of SQL Server database files called LocalDb. When you add an SQL Server Database file to a project a LocalDb file is added to the App_Data folder. Simply right click on the App_Data folder and add an SQL Server Database as a new Item found under the New Item Data tab. If you do not have an App_Data folder then add that first by Add New ASP.NET Folder.

To modify or add new tables and data to the database use the Server Explorer view usually shown on the left hand window. If it is not showing then use the View menu to add it. By default the database connection is closed indicated by a red cross next to the database name. To open it, click refresh or the triangle symbol next to the database name.

To add a new table to the database right click on the Table folder and select Add New Table. A table designer is loaded which shows the SQL Code produced by the designer as the table details are altered. The only way of naming the Table is in the code view. Change that from Table to a sensible table name such as Customers. The name should be plural as the table will contain many customer records. The name does not need to have either tbl in from, or Table on the end as it is clearly in the Table folder.

Visual Studio Index