How to create table in Entity Framework

Posted by Ishan7 under Sql Server on 12/10/2020 | Points: 10 | Views : 254 | Status : [Member] | Replies : 0
My project created in WPF and EntityFramework
I want to create a table in SQL server using Script
Code like this

public override void Up()
{
Execute.Sql(@"CREATE TABLE [dbo].[Exam](
[exam_id] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
[subject_name] [nvarchar](50) NOT NULL,
[emp_id] [numeric](18, 0) NOT NULL,
[department_id] [numeric](18, 0) NOT NULL,
CONSTRAINT [PK_Exam] PRIMARY KEY CLUSTERED
(
[exam_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO");
}




but not create it.
It throws exception
Exception is:

- InnerException {"The table name is not valid. [ Token line number (if known) = 1,Token line offset (if known) = 22,Table name = Exam ]"} System.Exception {System.Data.SqlServerCe.SqlCeException}

What is the mistake in my code?




Responses

(No response found.)

Login to post response