Entity Framework Core
Steps to use Entity Framework Core in an ASP.NET Core application
public class Officer { public Guid Id { get; set; } public string Name { get; set; } public string Gender { get; set; } public string Phone { get; set; } public string Department { get; set; } public string Position { get; set; } }namespace Entity_Framework_CRUD.Models { public class OfficerContext : DbContext { public OfficerContext(DbContextOptions<OfficerContext> options) : base(options) { } public DbSet<Officer> tbl_officer { get; set; } // This is the table name i.e tbl_officer, // We can name it anything we want, but it should be same as the table name in the database. } }builder.Services.AddDbContext<OfficerContext>(options => { options.UseSqlServer(builder.Configuration.GetConnectionString("connectionString")); });
CRUD Operations
Read Operation (List)
Create Operation
Read Operation (Single Record)
Update Operation
Delete Operation
Last updated