Jakxna360
Jakxna360

Reputation: 885

DbContextOptionsBuilder does not Contain a Definition for UseSQLServer after 5.0.11 Upgrade

Today we updated our Nuget packages for EntityFrameworkCore to version 5.0.11. Unfortunately, that seems to have messed up my VS environment. Whenever I try to compile I get the error message: 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?)

Both Microsoft.EntityFrameworkCore.SqlServer and Microsoft.EntityFrameworkCore.Tools match at version 5.0.11 after the upgrade.

I tried downgrading back to 5.0.7 but that did not fix the issue. Restarting the computer did not work. Neither did restarting Visual Studio 2019. I did clean and rebuild the project but that also kept the same error message. The project does reference using Microsoft.EntityFrameworkCore; and it is listed within my .csproj file. Any other advice to resolve this issue is appreciated.

Edit: I should say that this only occurs on my machine so it's more of an issue with the environment. No other changes have been made other than upgrading the nuget package. I did upgrade back to 5.0.11 and it matches what is in the .csproj file. Wondering if this happened to anyone else as well.

Upvotes: 0

Views: 2971

Answers (1)

JHBonarius
JHBonarius

Reputation: 11271

From experience I know that just cleaning the build doesn't remove everything. Especially when upgrading dependencies (packages) it's often required to manually delete the Bin and Obj directories of (all) the projects.

In some cases it's also required to delete the .vs and packages directories from (all) projects and solution. Don't do this while the solution is open in VS.

Upvotes: 1

Related Questions