Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
in .Net Framework by 11 11 15

I am using ASP.NET Core and I want to create a connection with the SQL Server.

 services.AddDbContext<BookStoreDbContext>(options =>

but I get this error 

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?)

1 Answer

0 like 0 dislike
by 23 25 40
selected by
Best answer

To solve this error "'DbContextOptionsBuilder' does not contain a definition for 'UseSqlServer'", you should add the Sqlite package

  1. Open your CMD > Go to the path of the project folder, then run this command :

     dotnet add package Microsoft.EntityFrameworkCore.Sqlite 
  2. Then use the EntityFrameworkCore package in your file

     using Microsoft.EntityFrameworkCore.Sqlite;
If you don’t ask, the answer is always NO!