forum

home / developersection / forums / how to use migration in code first entity framework?

How to use migration in code first entity framework?

Sushant Mishra 1846 12-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

public class Employee   
{       
    public int ID { get; set; }
        public string EmpName { get; set; }
        public int Salary { get; set; } } 


Context class 

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

Web.config

<connectionStrings>
    <add name="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