4

Not sure which assembly I should reference to, to remove this blocking error.

public void ConfigureServices(IServiceCollection services)
{
    // Add framework services.
    services.AddDbContext<QAContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
    // Add framework services.
    services.AddMvc();
}

Error CS1061 'DbContextOptionsBuilder' does not contain a definition for 'UseSqlServer' and no extension method 'UseSqlServer' accepting a first argument of type 'DbContextOptionsBuilder' could be found (are you missing a using directive or an assembly reference?)

Tassisto
  • 9,877
  • 28
  • 100
  • 157
  • type the following in Google Search `C# CS1061 'DbContextOptionsBuilder' does not contain a definition for 'UseSqlServer' and no extension method 'UseSqlServer' accepting a first argument of type 'DbContextOptionsBuilder' could be found` – MethodMan Jun 02 '17 at 21:05
  • Possible duplicate of ['DbContextOptionsBuilder' does not contain a definition for 'UseSqlServer'](https://stackoverflow.com/questions/40342137/dbcontextoptionsbuilder-does-not-contain-a-definition-for-usesqlserver) – Eris Jun 02 '17 at 21:48

2 Answers2

6

If you are using EntityFrameworkCore you must:

Add to Reference:

Microsoft.EntityFrameworkCore.SqlServer

Add to source file:

using Microsoft.EntityFrameworkCore;
Oleg Belousov
  • 509
  • 3
  • 8
3

First go to toolbar > Tools > NuGet Package Manager > Package Manager Console, And it will be open below type "Install-Package Microsoft.EntityFrameworkCore.SqlServer" and it will solved.

y3gb
  • 51
  • 2