Open Rick-Anderson opened 3 years ago
What's in the .proj file?
What is the DbContext
?
by @grenadin
@Rick-Anderson
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="Pages\Movies\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
</ItemGroup>
</Project>
After click the + and click "Add". You can see at the picture below. the scaffolding does not generate DbContext file in Data folder. and Data folder does not generate too.
@grenadin try changing all the versions from Version="5.0.4"
to Version="5.0.2"
@Rick-Anderson
After trying to change the <Version="5.0.4">
to <Version="5.0.2">
and use scaffolding tool. The scaffolding will bring the newest version update overlap on it from 5.0.2 to 5.0.4 again. and after the error will occur again. You can see on the link at my YouTube that I uploaded below.
scaffolding tool error
And I try to downgrade to .Net core 3.1 LTS but the problem occurred the same step as the 5.0 version. I think the problem might be from scaffolding tools. Thank you for your help.
Moved from https://github.com/dotnet/AspNetCore.Docs/issues/21968 and created by @grenadin
Issue also reported on SO
I cannot follow the step in the razor page tutorial. In the step add new scaffolding item step. see the error follow by a picture
in the first attempt.
and the second attempt.
and the Code Generation Log:
Finding the generator 'razorpage'... Running the generator 'razorpage'... Generating a new DbContext class 'RazorPagesMovie.Data.RazorPagesMovieContext' Attempting to compile the application in memory with the added DbContext. There was an error creating a DbContext :(10,19): error CS1001: Identifier expected (11,6): error CS1513: } expected (12,44): error CS8124: Tuple must contain at least two elements. (13,13): error CS1022: Type or namespace definition, or end-of-file expected at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.b__6_0()
(13,27): error CS8124: Tuple must contain at least two elements. at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
(14,9): error CS1022: Type or namespace definition, or end-of-file expected at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
(18,5): error CS1022: Type or namespace definition, or end-of-file expected at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
(19,1): error CS1022: Type or namespace definition, or end-of-file expected C:\Users\harir\source\repos\RazorPagesMovie\RazorPagesMovie\Startup.cs(30,13): error CS8389: Omitting the type argument is not allowed in the current context
And the csproj file
Actually. I have 2 laptop that installs Visual Studio 2019 and VSCode(Its error occur in the command line too). The error occurs on 2 laptops too. And I found scaffolding error either razor page, web api, or MVC, control if it involves using Entity Framework.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.