I’m trying to use this DBContext in a Post method to add a record…
[HttpPost(Name = "")]
public IEnumerable<Cookie> PostCookie([FromBody] Cookie data)
{
DbContextOptions<ReactWithASPDbContext> options = new
DbContextOptions<ReactWithASPDbContext>();
ReactWithASPDbContext dbContext = new ReactWithASPDbContext(options);
...
}
The DBContext class looks like this…
public class ReactWithASPDbContext : DbContext
{
public ReactWithASPDbContext(DbContextOptions<ReactWithASPDbContext> options):
base(options)
{
}
...
}
but the configuration is generating this error…
‘No database provider has been configured for this DbContext. A provider can be configured by overriding the ‘DbContext.OnConfiguring’ method or by using ‘AddDbContext’ on the application service provider. If ‘AddDbContext’ is used, then also ensure that your DbContext type accepts a DbContextOptions object in its constructor and passes it to the base constructor for DbContext.’
I’m assuming that I do not need to recreate the init stuff in the Program.cs file that creates an IApplicationBuilder etc. There should be a way to pass along the context once its created right?