{"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":"error","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/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Design/Design/Internal/DesignTimeServicesBuilder.cs#L167-L203","documentation":"InvalidOperationException thrown when the loaded provider assembly does not carry [DesignTimeProviderServices] attribute. That attribute names the IDesignTimeServices implementation that registers scaffolding/migration services; without it the design-time pipeline cannot find provider-specific services.","triggerScenarios":"A custom or third-party provider assembly is loaded successfully but is missing the DesignTimeProviderServicesAttribute. The runtime provider works but the design-time layer (migrations, scaffold) cannot locate its services factory.","commonSituations":"Building a custom EF provider and forgetting to decorate the assembly with [DesignTimeProviderServices(typeof(...))]; or referencing a provider shim/proxy assembly that forwards runtime calls but lacks the design-time hook.","solutions":["On the custom provider assembly, add [assembly: DesignTimeProviderServices(typeof(MyDesignTimeServices))] pointing at an IDesignTimeServices implementation.","Ensure the attribute's TypeName resolves to a concrete type implementing IDesignTimeServices in that assembly.","If using a third-party provider, upgrade it to a version that ships the attribute.","Verify the runtime provider assembly name passed to the tools is the one that carries the attribute (not a split runtime/design package mismatch)."],"exampleFix":"// before - custom provider assembly has no design-time attribute\n[assembly: AssemblyVersion(\"1.0.0.0\")]\n\n// after\nusing Microsoft.EntityFrameworkCore.Design;\n[assembly: DesignTimeProviderServices(typeof(MyProvider.Design.MyDesignTimeServices))]\n\npublic sealed class MyDesignTimeServices : IDesignTimeServices\n{\n    public void ConfigureDesignTimeServices(IServiceCollection services)\n        => services.AddSingleton<IDatabaseModelFactory, MyDatabaseModelFactory>();\n}","handlingStrategy":"validation","validationCode":"var attr = providerAssembly.GetCustomAttribute<DesignTimeProviderServicesAttribute>();\nif (attr is null)\n    throw new InvalidOperationException($\"{providerAssembly.GetName().Name} lacks [DesignTimeProviderServices]; add the attribute to its IDesignTimeServices type.\");","typeGuard":"static bool ProviderHasDesignTimeAttribute(Assembly a)\n    => a.GetCustomAttribute<DesignTimeProviderServicesAttribute>() is not null;\n","tryCatchPattern":"try { /* design-time op */ }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"DesignTimeProviderServices\"))\n{ /* decorate the provider assembly with the attribute pointing at its IDesignTimeServices */ }","preventionTips":["Decorate every custom provider assembly with [assembly: DesignTimeProviderServices(typeof(X))].","Ensure the TypeName resolves to a concrete IDesignTimeServices in the same assembly.","Cover provider design-time setup with a unit test that asserts the attribute exists."],"tags":["design-time","ef-tools","provider","attribute","scaffolding"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}