项目版本:.netcore2.2
我正在 .netcore2.2 中使用 N 层架构
当我定义以下配置时给出错误:
DbContextOptionsBuilder”不包含“usesqlserver”的定义,并且没有扩展方法“usesqlserver”
public class CustomerDataAccess : DbContext, ICustomerDataAccess
{
protected override void OnConfiguring(DbContextOptionsBuilder dbContextOptionsBuilder)
{
if (!dbContextOptionsBuilder.IsConfigured && _configuration.GetConnectionString("DMEBaseConnection") != null)
{
dbContextOptionsBuilder.UseSqlServer(_configuration.GetConnectionString("connectionstringname")); **//here give an error**
}
}
Run Code Online (Sandbox Code Playgroud)
启动.cs
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
}
// This method gets called …Run Code Online (Sandbox Code Playgroud) asp.net-core ×1