InvalidOperationException when the start-up class is not Program
- Dominant language
- C#
- Stars
- 818
- Forks
- 260
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 10
Description
## File a bug
### Include your code
Use triple-tick code fences for any posted code. For example:
```C#
var programClassNode = namespaceNode?.DescendantNodes()
.Where(node =>
node is ClassDeclarationSyntax cds &&
cds.Identifier
.ValueText.Contains("Program"))
.First();
```
### Include stack traces
```
System.AggregateException: One or more errors occurred. (Sequence contains no elements)
---> System.InvalidOperationException: Sequence contains no elements
at System.Linq.ThrowHelper.ThrowNoElementsException()
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
at Microsoft.DotNet.Scaffolding.Shared.Project.ProjectModifierHelper.GetStartupClassName(Document programDoc) in /home/dell/prog/Scaffolding/src/Shared/Microsoft.DotNet.Scaffolding.Shared/Project/ProjectModifierHelper.cs:line 126
at Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore.EntityFrameworkModelProcessor.Process() in /home/dell/prog/Scaffolding/src/Scaffolding/VS.Web.CG.EFCore/EntityFrameworkModelProcessor.cs:line 101
at Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore.EntityFrameworkServices.GetModelMetadata(String dbContextFullTypeName, ModelType modelTypeSymbol, String areaName, Boolean useSqlite) in /home/dell/prog/Scaffolding/src/Scaffolding/VS.Web.CG.EFCore/EntityFrameworkServices.cs:line 138
at Microsoft.VisualStudio.Web.CodeGenerators.Mvc.ModelMetadataUtilities.ValidateModelAndGetEFMetadata(CommonCommandLineModel commandLineModel, IEntityFrameworkService entityFrameworkService, IModelTypesLocator modelTypesLocator, String areaName) in /home/dell/prog/Scaffolding/src/Scaffolding/VS.Web.CG.Mvc/ModelMetadataUtilities.cs:line 52
at Microsoft.VisualStudio.Web.CodeGenerators.Mvc.Razor.EFModelBasedRazorPageScaffolder.GenerateCode(RazorPageGeneratorModel razorGeneratorModel) in /home/dell/prog/Scaffolding/src/Scaffolding/VS.Web.CG.Mvc/RazorPage/EFModelBasedRazorPageScaffolder.cs:line 93
at Microsoft.VisualStudio.Web.CodeGenerators.Mvc.Razor.RazorPageGenerator.GenerateCode(RazorPageGeneratorModel razorPageGeneratorModel) in /home/dell/prog/Scaffolding/src/Scaffolding/VS.Web.CG.Mvc/RazorPage/RazorPageGenerator.cs:line 82
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.b__8_0() in /home/dell/prog/Scaffolding/src/Scaffolding/VS.Web.CG.Core/ActionInvoker.cs:line 105
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) in /home/dell/.nuget/packages/microsoft.extensions.commandlineutils.sources/6.0.0-preview.3.21166.3/contentFiles/cs/netstandard1.0/CommandLine/CommandLineApplication.cs:line 374
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute() in /home/dell/prog/Scaffolding/src/Scaffolding/VS.Web.CG.Core/ActionInvoker.cs:line 54
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute() in /home/dell/prog/Scaffolding/src/Scaffolding/VS.Web.CG/CodeGenCommand.cs:line 93
```
### Include provider and version information
-
Microsoft.VisualStudio.Web.CodeGeneration.Design/Microsoft.DotNet.MSIdentity version: - 1.0.0
-
Target framework: (e.g. .NET 5.0) - 6.0.1
-
Operating system: - Linux x64 5.15.12-1-default
-
IDE: (e.g. Visual Studio 2019 16.3) - 1.63.2
Contributor guide
Assessment
This issue has not been assessed yet.