How To Create Database Table In Visual Studio
Here we consider how to create a database and table in visual studio.
Lets start with one example here.
Suppose we have a web application in visual studio.
FIrst of all, right click on the project icon and select Add --> New Item
A new window will appear. From Data section select SQL Server Database.
Give a suitable name for this mdf file.
When you click on the Add button, a warning message will come as shown below.
It says, the database file will be placed under App_Data Folder.
Now click on Yes Button inside this warning window.
On Solution explorer, under App_Data Folder, you can see both database files are placed.
For managing database, double click on .mdf file.
This will connect Server Explorer to the current database.
Now right click on Table icon inside Server Explorer.
And select Add New table.
Here specify your new table requirement and more columns.
On each row if you right click, you can select properties window for that column.
After appending colmns, its time to update to database.
For that click on update button as shown here.
Now a window will appear, click on Update database.
After Successful execution, you can see a message saying Update Completed Successfully.