First We need to create MVC project into solution then add following class on model folders .
namespace CRUDCodeFirstApproach.Models
{
public class User
{
[ Key]
public int User_ID { get; set; }
public string Username { get; set; }
public string Password { get; set; }
}
}
namespace CRUDCodeFirstApproach.Models
{
public class UserContext:DbContext
{
public DbSet<User> Users { get; set; }
}
}
Make sure you added the entity frame work package into project . Then add a MVC 5 controller with entity frame work options .
With this controller make sure you select the correct class then click add . After few minutes all the
necessary code will be generated for you by mvc tools .. Finally build your project and run it on localhost . Here is the screen shot when you run the project ..
Insert operation ..
List of User Record
Edit the users
Delete Users Records
No comments:
Post a Comment