Skip to content
Latchkey

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.

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?)

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

  1. Add the using for the extension namespace (e.g. using System.Linq;).
  2. If it is an external extension, add the PackageReference that provides it.
  3. 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 ""CS1061: ... no accessible extension method""?
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 "CS1061: ... no accessible extension method"?
Import the namespace or add the package

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card