Asp.net Core 8 Web Application With SQL Server Database Connection
public class Emplyee
{
public int Id { get; set; }
public string FirestName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string EmailAddress { get; set; }
public int PhoneNo { get; set; }
}
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> contextOptions) : base(contextOptions) { }
public DbSet<Emplyee> Emplyees { get; set; }
}
"ConnectionStrings": {
"DefualtConnection": "Data Source=.;Initial Catalog=company;Integrated Security=True;Trust Server Certificate=True"
},
builder.Services.AddDbContext<ApplicationDbContext>(options =>
{
options.UseSqlServer(builder.Configuration.GetConnectionString("DefualtConnection"));
});