error CS1061: 'X' does not contain a definition for 'Y' and no accessible extension method 'Y' accepting a first argument of type 'X' could be found
The member you call doesn’t exist on that type — typo, wrong type, missing using for an extension method, or an API removed in a newer version.
Seen on:
.NET
Meaning
Extension methods (LINQ, AddDbContext, UseSqlServer) need their namespace and package. Upgrading packages can remove/rename members.
Common causes
- Missing using for extension methods (System.Linq, Microsoft.EntityFrameworkCore)
- Package for the extension not installed (e.g. EF provider)
- Variable is a different type than assumed
- API removed/renamed in a newer version
⚡ Quick fix
- Add the using/package that provides the extension
- Check the variable’s actual type
- Look up the migration notes for renamed APIs
Detailed fix by platform
Shell
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
How to diagnose
- Type — Actual type of the expression
- Extension — Package and namespace
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- antiforgery token could not be decrypted ASP.NET Core: The antiforgery token could not be decrypted / The required antiforgery cookie is not present (400 Bad Request)
- CS0103 error CS0103: The name 'x' does not exist in the current context
- CS0246 error CS0246: The type or namespace name 'X' could not be found (are you missing a using directive or an assembly reference?)
Most viewed in .NET
- NullReferenceException System.NullReferenceException: Object reference not set to an instance of an object
- FileNotFoundException assembly Could not load file or assembly 'X, Version=…' or one of its dependencies
- InvalidOperationException InvalidOperationException: Unable to resolve service for type 'X' while attempting to activate 'Y'
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026