{"record":{"id":"a8b35de2bfdda075","repo":"dotnet/efcore","slug":"unable-to-find-expected-assembly-attribute-design","errorCode":null,"errorMessage":"Unable to find expected assembly attribute [DesignTimeProviderServices] in provider assembly '{runtimeProviderAssemblyName}'. This attribute is required to identify the class which acts as the design-time service provider factory for the provider.","messagePattern":"Unable to find expected assembly attribute \\[DesignTimeProviderServices\\] in provider assembly '(.+?)'\\. This attribute is required to identify the class which acts as the design-time service provider factory for the provider\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"critical","filePath":"src/EFCore.Design/Design/Internal/DesignTimeServicesBuilder.cs","lineNumber":185,"sourceCode":"            }\n\n            throw new OperationException(message, ex);\n        }\n\n        var providerServicesAttribute = providerAssembly.GetCustomAttribute<DesignTimeProviderServicesAttribute>();\n        if (providerServicesAttribute == null)\n        {\n            var message = DesignStrings.CannotFindDesignTimeProviderAssemblyAttribute(\n                provider);\n\n            if (!throwOnError)\n            {\n                _reporter.WriteVerbose(message);\n\n                return;\n            }\n\n            throw new InvalidOperationException(message);\n        }\n\n        var designTimeServicesType = providerAssembly.GetType(\n            providerServicesAttribute.TypeName,\n            throwOnError: true,\n            ignoreCase: false)!;\n\n        _reporter.WriteVerbose(DesignStrings.UsingProviderServices(provider));\n\n        ConfigureDesignTimeServices(designTimeServicesType, services);\n    }\n\n    private static void ConfigureDesignTimeServices(\n        Type designTimeServicesType,\n        IServiceCollection services)\n    {\n        Check.DebugAssert(designTimeServicesType != null, \"designTimeServicesType is null.\");\n","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Design/Design/Internal/DesignTimeServicesBuilder.cs#L167-L203","documentation":"The provider assembly loaded fine, but it has no [DesignTimeProviderServices] attribute, which EF uses to locate the class that registers the provider's design-time services (scaffolding, SQL generators, etc.). This almost always means the assembly is not a real EF Core provider, or is an incompatible/old one. It is thrown as InvalidOperationException (not OperationException) because it indicates a corrupt or wrong provider rather than user input.","triggerScenarios":"ConfigureProviderServices succeeds in loading the assembly (line 156) but providerAssembly.GetCustomAttribute<DesignTimeProviderServicesAttribute>() returns null at line 172. Happens when UseSqlServer points at a plain library, a hand-rolled provider lacking the attribute, or a provider built against a different EF Core design API.","commonSituations":"Pointing Use*[provider] at an ADO.NET driver instead of the EF provider (e.g. System.Data.SqlClient vs Microsoft.EntityFrameworkCore.SqlServer); using a community provider that dropped design-time support; a custom provider whose DesignTimeProviderServicesAttribute was removed in a refactor.","solutions":["Verify the package is an EF Core provider: install the official Microsoft.EntityFrameworkCore.<Provider> package.","If using a custom/community provider, ensure its assembly is decorated with [DesignTimeProviderServices(typeof(...))] and that the design-time services type exists.","Upgrade the provider to a version that matches your EF Core runtime version.","Remove any stray Use* call that references a non-provider assembly."],"exampleFix":"// before: wrong package\noptions.UseSqlServer(connection); // but only System.Data.SqlClient referenced\n// after\n// dotnet add package Microsoft.EntityFrameworkCore.SqlServer\noptions.UseSqlServer(connection);","handlingStrategy":"validation","validationCode":"var attr = Assembly.Load(providerAssemblyName)\n    .GetCustomAttribute<DesignTimeProviderServicesAttribute>();\nif (attr is null) throw new InvalidOperationException($\"'{providerAssemblyName}' is not an EF Core provider (missing DesignTimeProviderServices attribute).\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only official Microsoft.EntityFrameworkCore.<Provider> packages.","For custom providers, always decorate the assembly with [DesignTimeProviderServices].","Run a smoke-test that loads the provider and checks for the attribute."],"tags":["efcore","provider","design-time","configuration"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}