C# "CS1061: no definition and no accessible extension method" (missing using) in CI
By Kaveh Alemi·Latchkey
This CS1061 variant is specifically about extension methods: the instance method does not exist on the type, and the extension that would supply it is not in scope because its namespace is not imported (commonly System.Linq or an EF Core extension namespace).
What this error means
The build fails with CS1061 mentioning "no accessible extension method ... could be found (are you missing a using directive or an assembly reference?)". It is deterministic.
dotnet
Query.cs(14,30): error CS1061: 'IEnumerable<Order>' does not contain a definition for
'Where' and no accessible extension method 'Where' accepting a first argument of type
'IEnumerable<Order>' could be found (are you missing a using directive?)
Diagnose it: SDK version and restore first
Most .NET CI failures are an SDK mismatch or a restore that did not happen. global.json pins the SDK, and if the runner does not have that exact version the failure message is about the project rather than the SDK.
Terminal
dotnet --info
cat global.json 2>/dev/null
# restore explicitly so a restore failure is not reported as a build failure
dotnet restore --verbosity normal
dotnet build --no-restore -warnaserror
Common causes
The extension method namespace is not imported
LINQ (System.Linq), EF Core (Microsoft.EntityFrameworkCore), or another extension lives in a namespace the file does not using, so the method is invisible.
The providing package is not referenced
The extension method ships in a package the project never restored, so even the right using would not resolve.
How to fix it
Import the namespace or add the package
Add the using for the extension namespace (e.g. using System.Linq;).
If it is an external extension, add the PackageReference that provides it.
Rebuild.
C#
using System.Linq;
using Microsoft.EntityFrameworkCore;
How to prevent it
Enable ImplicitUsings to bring System.Linq into scope by default.
Keep extension-providing packages referenced where they are consumed.
Frequently asked questions
What causes C# "CS1061: no definition and no accessible extension method" (missing using) in CI?
There are 2 common causes: the extension method namespace is not imported and the providing package is not referenced. LINQ (System.Linq), EF Core (Microsoft.EntityFrameworkCore), or another extension lives in a namespace the file does not using, so the method is invisible.
How do I fix C# "CS1061: no definition and no accessible extension method" (missing using) in CI?
Import the namespace or add the package. Add the using for the extension namespace (e.g.
What does C# "CS1061: no definition and no accessible extension method" (missing using) in CI actually mean?
The build fails with CS1061 mentioning "no accessible extension method ...
How do I stop C# "CS1061: no definition and no accessible extension method" (missing using) in CI happening again?
Enable ImplicitUsings to bring System.Linq into scope by default. The prevention section lists 2 changes that keep it from recurring.