Hi,
I am trying to get data from DB and move them to list as shown below:
public JsonResult GetEvents()
{
using (ApplicationDbContext dc = new ApplicationDbContext())
{
var events = dc.CalEvents.ToList();
return new JsonResult(new { Data = events, JsonRequestBehavior = System.Web.Mvc.JsonRequestBehavior.AllowGet });
}
}
but the following error comes up in the ApplicationDbContext
There is no argument given that corresponds to the required parameter 'options' of 'ApplicationDbContext.ApplicationDbContext(DbContextOptions<ApplicationDbContext>)'
using ExpenseTracker.Models;
using ExpenseTrackerApplication2023;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
namespace ExpenseTracker.Data
{
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ApplicationUser>()
.Property(e => e.firstName)
.HasMaxLength(250);
modelBuilder.Entity<ApplicationUser>()
.Property(e => e.lastName)
.HasMaxLength(250);
}
public DbSet<Transaction> Transaction { get; set; }
public DbSet<Category> Categories { get; set; }
public DbSet<S3FileDetails> S3FileDetails { get; set;}
public DbSet<CalEvents> CalEvents { get; set; }
}
}