C# "CS1061: no definition and no accessible extension method" (missing using) in CI
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.
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?)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
usingfor the extension namespace (e.g.using System.Linq;). - If it is an external extension, add the
PackageReferencethat provides it. - Rebuild.
using System.Linq;
using Microsoft.EntityFrameworkCore;How to prevent it
- Enable
ImplicitUsingsto bring System.Linq into scope by default. - Keep extension-providing packages referenced where they are consumed.