C
C#3y ago
Hotz

[SOLVED] What is happening in this snippet?

My guess is: since AppDbContext inherits from DbContext, it also inherits the ctor and all the parameters that the ctor takes. This way, AppDbContext's ctor is being overwritten so that it only has the options parameter from its parent class. Is this correct?
public class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
{

}
}
public class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
{

}
}
2 Replies
Bladesfist
Bladesfist3y ago
It's going to take your options object and pass it into the base class constructor that accepts an options parameter, once the base class constructor is finished it will run the body of the AppDbContext constructor If there is no empty constructor in your base class then this is mandatory, if there is then this is an optional way of determining which constructor to use.
Hotz
HotzOP3y ago
Alright, thanks a bunch!
Want results from more Discord servers?
Add your server