dotnet / Scaffolding

Code generators to speed up development.
MIT License
642 stars 229 forks source link

Scaffolding MVC controller using EF #463

Closed chaitanyabagrait closed 5 years ago

chaitanyabagrait commented 7 years ago

I created a new project of asp.net core web application using .net framework.

Then I created a model with its attribute and also have created a key in the model.

When I am trying to scaffold using the entity framework which adds controller and view I am getting error. Please find the error attached with this question. error

current webapplication.csproj

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup Label="Globals">
    <SccProjectName>SAK</SccProjectName>
    <SccProvider>SAK</SccProvider>
    <SccAuxPath>SAK</SccAuxPath>
    <SccLocalPath>SAK</SccLocalPath>
  </PropertyGroup>

  <PropertyGroup>
    <TargetFramework>net452</TargetFramework>
    <RuntimeIdentifier>win7-x86</RuntimeIdentifier>
  </PropertyGroup>

  <PropertyGroup>
    <UserSecretsId>aspnet-webapplication</UserSecretsId>
  </PropertyGroup>

  <ItemGroup>
    <Content Include="wwwroot\css\animate.min.css" />
    <Content Include="wwwroot\lib\moment\moment.min.js" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" PrivateAssets="All" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.1" PrivateAssets="All" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0" PrivateAssets="All" />
    <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.1" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0" PrivateAssets="All" />
    <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
    <DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0" />
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
  </ItemGroup>
</Project>
chaitanyabagrait commented 7 years ago

Hi @prafullbhosale , Is there any solution to my error ? I can see it as closed but can't see the fix for it.

prafullbhosale commented 7 years ago

@chaitanyabagrait apologies about the delay here, but the issue isn't closed. The issue #465 is closed as a dupe of this one. This error usually happens if there is a mismatch in the dotnet CLI and Visual studio. Can you provide the versions of both the CLI and VS?

The CLI version can be found out by running dotnet --info on a commandline.

vijayrkn commented 5 years ago

This is fixed.