简体   繁体   中英

Can't find ApplicationDbContext in DbContextOptions

I am new with .net framework, and i am stuck with this ApplicationDbContext, Here is sample of my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;

namespace Rocky.Data
{
public class ProjectDbContext:DbContext
{
    public ProjectDbContext(DbContextOptions<ApplicationDbContext> options): base(options)
    {

    }
}
}

Your problem is the ApplicationDbContext is not a module it's the class name of the contractor. So replace the ApplicationDbContext with ProjectDbContext. and your problem with be solved.

Here is the code you:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;

namespace Rocky.Data
{
public class ProjectDbContext:DbContext
{
    public ProjectDbContext(DbContextOptions<ProjectDbContext> options): base(options)
    {

    }
}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM