Node is saved as draft in My Content >> Draft
-
Code First approach in Entity framework
In the code first approach we should be to create the class for defining the attributes for the DBContext

So lets first create a class for defining attributes
public class Employee
{
public Employee ()
{
}
public int EmployeeID { get; set; }
public string Name { get; set; }
}
After doing this, we will create a context class that will implement the attributes.
Database name and table name should be specified in this context class.
ublic class Context: DbContext
{
public Context(): base()
{
}
public DbSet<Employee> Employees { get; set; }
}
For consuming this we need to create a separate application or we will create a class that will implement these methods
using (var ctx = new Context())
{
Employee emp = new Employee() { name = "Himanshu" };
ctx.Employees.Add(emp);
ctx.SaveChanges();
}
0 Comment(s)