.NET CORE 3.1 使用 EntityframeworkCore 時發生找不到 UseSqlServer 之 Error

  • 1562
  • 0

於CORE 3.1 使用 EntityframeworkCore  留意套件使用,於startup註冊時

services.AddDbContext<DocumentMgrContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DMGRContext")));

會報下列錯誤:

Entity Framework core : DbContextOptionsBuilder' does not contain a definition for 'usesqlserver' and no extension method 'usesqlserver'

PM > Install-Package Microsoft.EntityFrameworkCore.SqlServer

如果是直接從nuget下載 Microsoft.EntityFrameworkCore 則因該method不存在,正確的安裝套件為上述