PART 3: Create New Database and Table for Entity Framework

This project is about storing and retrieving Book Details in the library so we will create database and table according to the project.
There are 5 parts in this project and this is 3rd Part.
PART 3:

Step 1:

Create Database LibraryDB. Open Server Explorer in Visual Studio. Go to View > Server Explorer.

Create Database for EF

Step 2:

Right Click on Data Connections and click on Create New SQL Server Database.

Create Database for EF

Step 3:

Give Server Name as follows and Create Database LibraryDB.

Step 4:

Add a New Table BookDetails in the database. Expand LibraryDB in server explorer and right click on Tables and click on Add New Tables.

Create Database for EF  

Step 5:

Create a table as mentioned in picture. After designing table click on Update button to save it into the database.

Create Database for EF

Step 6: SQL Script

CREATE TABLE [dbo].[BookDetails]
(
    [Id] INT NOT NULL PRIMARY KEY IDENTITY, 
    [BookName] NVARCHAR(50) NULL, 
    [Price] NVARCHAR(50) NULL, 
    [Category] NVARCHAR(50) NULL, 
    [AuthorName] NVARCHAR(50) NULL, 
    [Edition] NVARCHAR(50) NULL, 
    [BookCondition] NVARCHAR(50) NULL, 
    [Available] NCHAR(10) NULL
)

Summary:

In this chapter, you created SQL Database and a Table. In the next chapter, we will Install Entity Framework and Create Data Model.

 

Share your thought