forum

Home / DeveloperSection / Forums / How to use migration in code first entity framework?

How to use migration in code first entity framework?

Sushant Mishra155712-Sep-2017

I am facing a problem while using code first approach in MVC. I have made the class of employee, context class and connection string. Still my database not generated. I don’t know how to use migration. See the code below:

Thanks in advance 

Employee class

publicclassEmployee    {         publicint ID { get; set; }
        publicstring EmpName { get; set; }
        publicint Salary { get; set; } } 


Context class 

publicclassDepartmentDB_Context: DbContext {         public DepartmentDB_Context() : base("DepartmentDB_Context") { }
        publicDbSet<Employee> EmployeeTable { get; set; } } 

Web.config

<connectionStrings>
    <addname="DepartmentDB_Context"connectionString="data source=.; User Id=sa; Password=1234; initial catalog=DepartmentDB_Context;"providerName="System.Data.SqlClient"/>


Updated on 12-Sep-2017

Can you answer this question?


Answer

1 Answers

Liked By