I created a new ASP.NET project using this command
dotnet new mvc --auth Individual
It generates only Registration and Login actions. I need also create, read, update and delete actions for products model. But I could not create the DatabaseContext instance. I tried to create an object like this:
private ApplicationDbContext ctx = new ApplicationDbContext();
It says an error:
There is no argument given that corresponds to the required formal parameter 'options' of 'ApplicationDbContext.ApplicationDbContext(DbContextOptions)' [project-name]
This is the ApplicationDbContext.cs file:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
// Customize the ASP.NET Identity model and override the defaults if needed.
// For example, you can rename the ASP.NET Identity table names and more.
// Add your customizations after calling base.OnModelCreating(builder);
}
}
So how to create the object of ApplicationDbContext class?