How to fix 'DbContextOptionsBuilder' does not contain a definition for 'UseSqlServer'

This post shows you how to fix 'DbContextOptionsBuilder' does not contain a definition for 'UseSqlServer' and no accessible extension method 'UseSqlServer'.

Error

Severity Code Description Project File Line Suppression State

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

To solve the problem you can right click on your project, then select Manage Nuget Packages, finally install it to your ASP.Net Core project,

PM > Install-Package Microsoft.EntityFrameworkCore.SqlServer