AddDbContext was called with configuration, but the context type ‘MyContext’ only declares a parameterless constructor?

As the error said it if you configure your MyContext through AddDbContext then you need too add a constructor that receive a parameter of type DbContextOptions<MyContext> into your MyContext class like below

public MyContext(DbContextOptions<MyContext> options)
    : base(options)
{ }

If you don’t do that, ASP.Net Core will not be able to inject the configuration you set with AddDbContext.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)