{"record":{"id":"f3ad5c9b69065932","repo":"dotnet/efcore","slug":"the-wildcard-can-only-be-used-with-commands-th","errorCode":null,"errorMessage":"The wildcard '*' can only be used with commands that run for all contexts found. Specify a context name for this command.","messagePattern":"The wildcard '\\*' can only be used with commands that run for all contexts found\\. Specify a context name for this command\\.","errorType":"exception","errorClass":"OperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Design/Design/Internal/DbContextOperations.cs","lineNumber":456,"sourceCode":"        return !string.IsNullOrWhiteSpace(subPath)\n            ? string.Join(\n                \".\",\n                subPath.Split(\n                    [Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar], StringSplitOptions.RemoveEmptyEntries))\n            : null;\n    }\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public virtual ContextInfo GetContextInfo(string? contextType, string? connectionString = null)\n    {\n        if (contextType == \"*\")\n        {\n            throw new OperationException(DesignStrings.WildcardNotSupported);\n        }\n\n        using var context = CreateContext(contextType);\n\n        if (connectionString != null)\n        {\n            context.Database.SetConnectionString(connectionString);\n        }\n\n        var info = new ContextInfo { Type = context.GetType().FullName! };\n\n        var provider = context.GetService<IDatabaseProvider>();\n        info.ProviderName = provider.Name;\n\n        if (((IDatabaseFacadeDependenciesAccessor)context.Database).Dependencies is IRelationalDatabaseFacadeDependencies)\n        {\n            try\n            {","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Design/Design/Internal/DbContextOperations.cs#L438-L474","documentation":"Thrown by DbContextOperations.GetContextInfo when contextType equals the wildcard '*'. GetContextInfo returns information about a single context and cannot meaningfully iterate all contexts, so the wildcard (used by drop/optimize for 'all contexts') is explicitly rejected here.","triggerScenarios":"Calling 'dotnet ef dbcontext info --context *' or invoking GetContextInfo with a wildcard context name. The method requires exactly one context.","commonSituations":"Copy-pasting a wildcard '--context *' from a database-drop or optimize command into a 'dbcontext info' call. Scripting that passes '*' uniformly across EF commands without realizing info is single-context.","solutions":["Pass a specific context name to 'dbcontext info' instead of the wildcard: '--context MyContext'.","Omit --context entirely if there is exactly one context; the tool will pick it.","If you need info on multiple contexts, call the command once per context name."],"exampleFix":"# before\ndotnet ef dbcontext info --context *   # throws WildcardNotSupported\n\n# after\ndotnet ef dbcontext info --context MyContext","handlingStrategy":"validation","validationCode":"if (contextType == \"*\")\n    throw new InvalidOperationException(\"GetContextInfo requires a single context; pass a specific name.\");\nops.GetContextInfo(contextType, connectionString);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass '*' to 'dbcontext info'; it is single-context only.","Pass an explicit context name or omit --context when exactly one exists."],"tags":["design","ef-tools","dbcontext","wildcard"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}