Ошибка генерации кода

В статье описаны причины сообщения «Ошибка генерации сертификата», представлены способы решения возникшей проблемы.

Ошибка генерации сертификата в Личном кабинете налогоплательщика

При попытке получения новой электронной подписи (ЭП) пользователь Личного кабинета налогоплательщика на сайте ФНС может столкнуться с сообщением «Ошибка генерации сертификата. Попробовать еще раз». После повторной попытки проходит какое-то время, после чего ошибка возникает вновь. Обычно это связано с проблемами в работе серверов сайта nalog.ru, которые испытывают перегрузки в связи с массовым наплывом пользователем. Давайте разберёмся, почему происходит ошибка, и как её исправить.Окно ошибки генерации сертификата

Содержание

  1. Особенности функционала сертификата подписи уполномоченного лица
  2. Причины возникновения ошибки генерации сертификата в личном кабинете ФНС
  3. Как исправить проблему в ЛК налогоплательщика
  4. Заключение

Особенности функционала сертификата подписи уполномоченного лица

Как известно, бумажную волокиту в финансовой отчётности всё чаще заменяет электронный документооборот. Он позволяет убыстрить процесс передачи отчётности предприятия в ФНС, упростить её проверку и выдачу соответствующего вердикта контролирующих органов.

Одним из инструментов электронного документооборота является «Личный кабинет налогоплательщика» на сайте ФНС. Благодаря его возможностям вы можете контролировать расчёты по имущественным налогам, отслеживать ход проверки поданных вами деклараций, просматривать данные об доходам поданных налоговыми агентами в виде 2-НДФЛ. Однако иногда пользователи могут сталкиваться с ошибкой генерации сертификата.

С 01 апреля 2015 года в Налоговый Кодекс РФ был внесён ряд изменений, связанных со сменой статуса «Личного кабинета налогоплательщика». Пользователи ЛК получили возможность отправлять в ФНС налоговые декларации, подписанные квалифицированной электронной подписью. Подписанные ЭЦП электронные документы признаются равноценными их бумажным аналогам.

Уведомление о подписании электронной подписью

Подписанные ЭЦП документы приравниваются к подписанным бумажным аналогам

Получить в пользование такую электронную подпись вы можете с помощью функционала «Личного кабинета» в разделе «Профиль». Вам предлагается два вида хранения такой ЭП – в виде ключа на вашем компьютере, либо на сервере налоговой службы. Сертификат ключа проверки ЭП действует в течение 1 года. По истечению срока действия сертификата вам будет необходимо получить новый сертификат с помощью функционала ЛК.

Варианты хранения электронной подписи

Это интересно: Как работает Личный Кабинет на ресурсе оператора фискальных данных «Ярус».

Причины возникновения ошибки генерации сертификата в личном кабинете ФНС

При выполнении процедуры получения новой ЭЦП пользователи могут столкнуться с сообщением «Ошибка генерации сертификата». Повторные попытки соединения с сервером обычно никак не решают проблему. Система зависает на какое-то время, после чего ошибка генерации сертификата появляется вновь.

Её причинами является следующее:

  • Сбои в работе серверов ФНС, вызванные различными причинами. Довольно часто этой причиной является наплыв пользователей на сайт ФНС в периоды сдачи отчётности (дни подачи налоговых деклараций и других выплат физических лиц). Поскольку большая часть подобной отчётности выпадает на первый квартал, то наибольшее число проблем наблюдается именно в указанное время. Сервера не справляется с перегрузками, и получение ЭЦП становится невозможным. Также проблемы наблюдались после перехода сайта ФНС на его обновлённую версию;
  • На сайте ФНС проводятся какие-либо технические работы. Последние обычно связаны с нормализацией функционала сайта;
  • Пользователем не произведена установка на его ПК дополнительных программ для генерации кодов. В связи с этим сервис не может найти станцию для сохранения необходимых данных налогоплательщика;
  • Брандмауэр (антивирус) пользователя блокирует подключение к ресурсу ФНС;
  • В системе имеются расширения (дополнения) для браузера, которые также дезорганизуют корректную работу с сайтом nalog.ru.

Давайте разберёмся, как исправить ошибку генерации электронного сертификата в вашем Личном кабинете налогоплательщика

Как исправить проблему в ЛК налогоплательщика

Для того, чтобы избавиться от проблемы с генерацией сертификата, необходимо сделать следующее:

  • Попробуйте повторить процедуру создания ЭП через какое-то время. Многим пользователям удалось получить ЭП через 1-3 суток после осуществления первой попытки. Наплыв на сервера немного спал, техслужба исправила возникшие проблемы, и регистрация ЭП прошла без проблем;
  • Просмотрите график проведения технических работ на сайте ФНС. Если вы пытаетесь связаться с сайтом в день таких работ, лучше перенести процедуру генерации ЭЦП на другой день;Сообщение о технических работах
  • Временно отключите ваши антивирус и брандмауэр с целью убедиться, что они не выступают факторами возникновения проблемы. Их отключение поможет устранить ошибку генерации документа в ЛК на сайте ФНС;
  • После отправки вашего запроса на регистрацию электронного ключа выйдите из Личного кабинета, а затем войдите обратно;
  • Просмотрите, имеются ли на вашем веб-навигаторе установленные расширения (дополнения), способные влиять на ваше интернет-подключения к сайту ФНС. Довольно часто такими инструментами является различные загрузчики (уровня «MediaGet» и аналогов), способные влиять на стабильность подключения браузера к различным сайтам. Если таковые имеются, временно отключите (удалите) их;
  • Попробуйте использовать другой браузер. Хорошие результаты даёт использование браузера Гугл Хром, позволяющее решить проблему налогоплательщиков на nalog.ru;Картинка Google Chrome
  • Лично обратитесь в отделение ФНС с ИНН и паспортом.

Читайте также: Пришло заказное письмо от ФКУ Налог-Сервис ФНС.

Заключение

В нашей статье мы разобрали, почему возникает ошибка генерации электронного сертификата при работе с  Личным кабинете налогоплательщика, и как это исправить. Обычно её причиной является наплыв пользователей на сервера ФНС во время сдачи отчётности (наиболее часто это первый квартал года). Рекомендуем подождать какое-то время (1-3 суток), после чего попробуйте вновь получить новую ЭП. Если же проблема продолжает повторяться на протяжении недели, рекомендуем обратиться в техническую поддержку сайта nalog.ru. И в соответствующем письме обрисовать возникшую у вас проблему.

Опубликовано 12.06.2019 Обновлено 10.06.2021

I am trying to add controller to my solution in ASP.NET Core project:

When I try to do so I get this error:

I get the same message for adding minimal dependencies and full dependencies for controller.

Wai Ha Lee's user avatar

Wai Ha Lee

8,41977 gold badges60 silver badges90 bronze badges

asked Jun 12, 2017 at 22:33

user8038446's user avatar

5

I also had this issue. «Add Controller>API Controller with actions, using Entity Framework» would give the «Package Restore Failed» error.

As Anish stated, it seems to be due to package versions being mis-aligned. I was able to resolve this issue using «Manage NUGET Packages for Solution», then performing an «Update All». This set my AspNetCore version to 2.1.5 and resolved my «Package Restore Failed» error, but then led to another error, «NETCore version 2.1.5 not found». Apparently the scaffolding code generator needs the AspNetCore and the NETCore versions to be in sync, so I manually downloaded and installed the NETCore version 2.1.5 from Microsoft Downloads. This worked, and I was finally able to generate Controllers.

answered Oct 17, 2018 at 14:29

Scott Duncan's user avatar

Scott DuncanScott Duncan

9911 gold badge10 silver badges22 bronze badges

4

I was getting the same error while making a new controller.
I’ve fixed it like this.
Actually, VS only had the Offline Package source and could not resolve the packages needed.

Add the online reference:
Tools > nuget package manager > package manager settings > Package Sources

Add source: https://api.nuget.org/v3/index.json

answered Aug 18, 2019 at 5:47

Drashtant Solanki's user avatar

1

If no answer works for you, try running the code generator from the command line.

For my sln with multiple projects, with net 5 and some NuGet packages of 5.0.5 and some of 5.0.2, Only code generator through the command line worked. Make Sure it is installed.

or install it by the following command

dotnet tool install -g dotnet-aspnet-codegenerator

or update it by the following command

dotnet tool update -g dotnet-aspnet-codegenerator

The basic code generator commands can be found here

Some of them are:

Generator           Operation
area                Scaffolds an Area
controller          Scaffolds a controller
identity            Scaffolds Identity
razorpage           Scaffolds Razor Pages
view                Scaffolds a view

For example:

dotnet-aspnet-codegenerator identity --dbContext MyDbContextClass

To get help:

dotnet-aspnet-codegenerator [YourGenerator] -h

answered Apr 27, 2021 at 22:45

Sayyed Dawood's user avatar

2

  1. VS2019 [5.0].

  2. Update NuGet Packages (Tools -> Nuget Package Manager -> Manage
    NuGet packages for solution -> Click on the Updates tab, select all
    and run update.

  3. Solution -> Clean

  4. solution -> Build

  5. create a Controller.

I try everything but the above method work for me

answered Jan 2, 2021 at 17:55

nitin shinde's user avatar

I encountered this issue with net5.0, specifically against version 5.0.5 of some dependencies. I downgraded my nuget packages from 5.0.5 to 5.0.4 for these:

"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="5.0.4"
"Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.4"
"Microsoft.AspNetCore.Identity.UI" Version="5.0.4" 
"Microsoft.EntityFrameworkCore.Tools" Version="5.0.4"

Dharman's user avatar

Dharman

29.3k21 gold badges80 silver badges131 bronze badges

answered Apr 12, 2021 at 12:15

wazdev's user avatar

wazdevwazdev

3234 silver badges11 bronze badges

4

I just recently ran into the same issue.

I resolved it by eventually taking a look at each individual .csproj files included in my solution and fixing all the versions of the microsoft libraries that were included.

I changed the metapackage that i was referencing from «Microsoft.AspNetCore.All» to «Microsoft.AspNetCore.App», i then loaded up the reference list on nuget for the «App» package and removed any references to libraries that are already included in the metapackage.

I then made sure that i fixed the versions of any outstanding packages to match the version of the metapackage that the project automatically chooses ie in my case 2.2.0.

Something that tripped me up was that if you have multiple projects included in your solution you need to make sure that they reference the same metapackage as if there is a version mismatch between projects included in your solution you will get this issue too.

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.2.5" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
  </ItemGroup>

Changed to this.

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />
  </ItemGroup>

answered Jun 26, 2019 at 11:05

Darryn Hosking's user avatar

Darryn HoskingDarryn Hosking

2,9982 gold badges18 silver badges20 bronze badges

2

I just had this problem whilst adding a controller to a Core API with Entity Framework project. I’m using VS 16.8.5 with the most recent EF core, version 5.03. The class containing my DBContext class referenced EF 5.03 .

I (eventually!) noticed whilst browsing Nuget that the various code generation packages (none of which were referenced in my .csproj file, I think because ASP.Net core ships as a framework since 3.0 but correct me if I am wrong someone!), and in particular Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCode were 5.02. I didn’t touch my ASP.Net project, instead I dowgraded the other EF projects to 5.02 and it solved the problem.

answered Feb 16, 2021 at 17:48

Peter's user avatar

PeterPeter

618 bronze badges

I had resolved it by update two files

Microsoft.VisualStudio.Web.CodeGeneration
and
Microsoft.VisualStudio.Web.CodeGeneration.Design

. Its version should be match with other packages version in application.

answered Jul 10, 2020 at 13:38

Trident's user avatar

TridentTrident

311 silver badge9 bronze badges

Just update the NUGET packages from the Nuget Package Manager.

answered Aug 24, 2020 at 11:42

Mamoon Rasheed's user avatar

i have same error. and Update NuGet Packages (Tools -> Nuget Package Manager -> Manage NuGet packages for solution -> Click on installed.
You need select Version with notice Dependencies.

Example my option is fine with:

Microsoft.AspNetCore.Identity.EntityFramework Core with version 3.1.12

Microsoft.EntityFrameworkCore.Tools with version 3.1.12

Microsoft.EntityFrameworkCore.SqlServer with version 3.1.12

Microsoft.VisualStudio.Web.CodeGeneration.Design with version 3.1.5

answered Feb 27, 2021 at 18:00

ToanTV's user avatar

ToanTVToanTV

1111 silver badge3 bronze badges

1

I had the problem with a blazor server application version 5.0.5 and Microsoft Identity scaffolding. The highest available version of the CodeGeneration.Design package was 5.0.2, so i downgraded the other Microsoft packages (specially EntityFramework) to 5.0.2 and it solved the problem.

answered Apr 17, 2021 at 21:46

Andi's user avatar

AndiAndi

212 bronze badges

2

Had exactly same problem, in my situation CodeGenerator was missing

I have added this item into ItemGroup in .csproj

<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />

answered Jul 5, 2019 at 11:21

Whistler's user avatar

WhistlerWhistler

1,8374 gold badges27 silver badges50 bronze badges

What fixed it for me after I couldn’t scaffold IdentityFramework was by

  1. Checking VS2019 for updates.
  2. Update NuGet Packages (Tools -> Nuget Package Manager -> Manage NuGet packages for solution -> Click on the updates tab, select all and run update.
  3. Retry scaffolding identity

answered Jun 28, 2020 at 13:27

Joshua Tromp's user avatar

Cleaning the solution showed me an error of NuGet packages needed to be updated! I updated them and build the solution. Build Successful and I was able to create the controller class.

answered May 25, 2021 at 7:11

joekevinrayan96's user avatar

Trying to add MVC controller with views using EF for MVC project using Net5.0.

Using the following NuGet packages specific versions worked for me, while the problem was solved by using less version than the version of Microsoft.EntityFrameworkCore, for both Microsoft.EntityFrameworkCore.SqlServer and Microsoft.EntityFrameworkCore.Tools, these packages are referenced in the MVC project.

The correct packages are:

<ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="5.0.7" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.7" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.6" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.6">
           <PrivateAssets>all</PrivateAssets>
           <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
            </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.7" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />   
</ItemGroup>

answered Jun 18, 2021 at 1:39

Ashraf Sada's user avatar

Ashraf SadaAshraf Sada

4,4012 gold badges44 silver badges46 bronze badges

I also faced this same error when i was trying to scaffold identity template. I resolve this issue by updating nuget packages of the two major project of concerns(I mean the the two projects that has something to do with what i was to implement).

answered Jul 30, 2021 at 13:16

sammy Akinsoju's user avatar

I am also facing this issue.

Please follow this step,

  • Clean Your Solution
  • Open Nuget Manager
  • Check this version Microsoft.EntityFrameworkCore (I am using 5.0.8)
  • Check this version Microsoft.EntityFrameworkCore.Design (I am using 5.0.8)
  • Check this version Microsoft.EntityFrameworkCore.Tools (I am using 5.0.8)
  • Check this version Microsoft.EntityFrameworkCore.SqlServer (I am using 5.0.8)
  • Check this version Microsoft.VisualStudio.Web.CodeGeneration.Design (I am using 5.0.2)

Check this image also

  • After that Rebuild your solution and Create Scaffolding Controller

answered Aug 14, 2021 at 10:59

Abdulla Sirajudeen's user avatar

1

The problem is that you have some of the older versions of nuget pacakges installed in your project and when you try to scaffold the Asp.net core tries to install the latest packages which are required for scaffolding at this point Asp.net core throws such exception.

I suggest you to update your nuget packages and than try scafolding.

Wai Ha Lee's user avatar

Wai Ha Lee

8,41977 gold badges60 silver badges90 bronze badges

answered Sep 23, 2020 at 13:32

Mohammed Rehan Javed Abdul Kar's user avatar

I know that some of you might still facing the same issue,
I just did the next in VS 2022,

1- Checked the depencendies on the current project.
enter image description here

2- Remove all of them

3- Go to dependencies
add a lower version

enter image description here

and the clean the solution and add the views.

answered Aug 15, 2022 at 19:14

Jose Antonio's user avatar

1

I also faced the same issue, Here is How I solved the Issue

There was an error running the selected code generation, ‘Package restore failed. Rolling back package canges for web’

1— Check if your Solution has multiple projects, please check their Target Dot.net Framework.(in my case it was .Net Standard 1.6 for class libraries & .NetCoreApp 1.0 for Web Project, I changed it to .NetCoreApp 1.1)

2— After having the same framework, clean the web project, Rebuilt and Add new Controller.

If its successful fine otherwise You might encounter another error e.g

‘There was an error running the code generator: ‘No executable found matching command «dotnet-aspnet-codegenerator»‘

If you have project.json file open it other wise open .csproj.user project in note pad, please add following


Please note based on your .net version you might have different version no.

You may find instruction in ScaffoldingReadMe.txt file if its generated in your project

answered Aug 17, 2017 at 4:12

Aamir's user avatar

AamirAamir

68510 silver badges11 bronze badges

All I had to do was open the properties of my web project and change the TargetFramework from 2.1 to 2.2. Or to match whatever version of the framework your business and object layer are using.

answered May 30, 2019 at 14:22

BBoyd's user avatar

BBoydBBoyd

411 bronze badge

Had the same problem, but updating all the NuGet Packages has solved the problem.
Right click on <your project name> file -> Manage NuGet Packages -> Updates -> Select all packages -> Update

answered Apr 27, 2020 at 9:13

Maksym Voloshko's user avatar

I’m running .NET Core (and Entity Framework Core) 3.1.x.

I got this exact error and tried updating all the nuget packages and other relevant solutions already mentioned in the answers here.

The issue was simply that my database server was not running (it runs on a local VM). In other words, my database context (i.e. ApplicationDbContext) mentioned in the ‘Add Controller…’ window, was not able to access the db. Once I started the db server, my scaffolding created without issue.

Keep also in mind, the model/class (i.e. table) that the controller and views were referencing had not been created yet (I hadn’t run add-migration yet). So, it just needed the db connection only.

It’s kind of a silly (obvious?) solution, but very misleading when looking at the ‘Package Restore Failed’ error message.

answered Jun 9, 2020 at 15:56

Sum None's user avatar

Sum NoneSum None

2,0032 gold badges23 silver badges31 bronze badges

I had a similar issue with entity framework core sqlite nuget packages. I installed sqlite and sqlite core packages fixed this. Probably a needy package is missing. Also make sure SQL Server and Server Agent are running. Check those on SQL Server Configuration > SQL Server Services > Right click on SQL Server or Server Agent and start the service then restart the server. Guess this might help someone

answered Aug 11, 2020 at 7:32

FF new's user avatar

FF newFF new

1031 gold badge1 silver badge11 bronze badges

My solution
-Vs2019 all nuget packages upgrade

answered Sep 21, 2020 at 21:21

wasdoska's user avatar

As someone mentioned earlier, I updated all NuGet packages from Tools->Nuget Package Manager -> Manage NuGet Packages for Solution -> Updates tab -> Update All. I was then able to add a controller with EF and have VS generate the associated views.

answered Oct 13, 2020 at 13:40

Phillip's user avatar

Just update all Nuget Packages , Clean Solution and the rebuild solution. It solve the issues for me.

answered Jan 30, 2021 at 15:26

vsharma10286's user avatar

I just updated EntityFrameworkCore from Version 3.1.10 to 3.1.13 and it solved the problem. My Project file looks like:

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

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.13" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.13" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.13" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.13">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.5" />
  </ItemGroup>

</Project>

answered May 3, 2021 at 6:59

Rahim's user avatar

RahimRahim

7896 silver badges6 bronze badges

I had this same issue when creating a new ‘Identity’ scaffolded item.
I managed to get this working by removing everything within the <ItemGroup> tags within the csproj file and running the code generator. The generator then installs packages that it needs.

answered May 22, 2021 at 10:27

Hannah's user avatar

HannahHannah

3215 silver badges8 bronze badges

In case you are using .net 5.0.14, downgrading every packages with version 5.0.14 from 5.0.14 to 5.0.12 fixed the problem for me.

answered Mar 10, 2022 at 7:15

KodFun's user avatar

KodFunKodFun

3033 silver badges8 bronze badges

I am trying to add controller to my solution in ASP.NET Core project:

When I try to do so I get this error:

I get the same message for adding minimal dependencies and full dependencies for controller.

Wai Ha Lee's user avatar

Wai Ha Lee

8,41977 gold badges60 silver badges90 bronze badges

asked Jun 12, 2017 at 22:33

user8038446's user avatar

5

I also had this issue. «Add Controller>API Controller with actions, using Entity Framework» would give the «Package Restore Failed» error.

As Anish stated, it seems to be due to package versions being mis-aligned. I was able to resolve this issue using «Manage NUGET Packages for Solution», then performing an «Update All». This set my AspNetCore version to 2.1.5 and resolved my «Package Restore Failed» error, but then led to another error, «NETCore version 2.1.5 not found». Apparently the scaffolding code generator needs the AspNetCore and the NETCore versions to be in sync, so I manually downloaded and installed the NETCore version 2.1.5 from Microsoft Downloads. This worked, and I was finally able to generate Controllers.

answered Oct 17, 2018 at 14:29

Scott Duncan's user avatar

Scott DuncanScott Duncan

9911 gold badge10 silver badges22 bronze badges

4

I was getting the same error while making a new controller.
I’ve fixed it like this.
Actually, VS only had the Offline Package source and could not resolve the packages needed.

Add the online reference:
Tools > nuget package manager > package manager settings > Package Sources

Add source: https://api.nuget.org/v3/index.json

answered Aug 18, 2019 at 5:47

Drashtant Solanki's user avatar

1

If no answer works for you, try running the code generator from the command line.

For my sln with multiple projects, with net 5 and some NuGet packages of 5.0.5 and some of 5.0.2, Only code generator through the command line worked. Make Sure it is installed.

or install it by the following command

dotnet tool install -g dotnet-aspnet-codegenerator

or update it by the following command

dotnet tool update -g dotnet-aspnet-codegenerator

The basic code generator commands can be found here

Some of them are:

Generator           Operation
area                Scaffolds an Area
controller          Scaffolds a controller
identity            Scaffolds Identity
razorpage           Scaffolds Razor Pages
view                Scaffolds a view

For example:

dotnet-aspnet-codegenerator identity --dbContext MyDbContextClass

To get help:

dotnet-aspnet-codegenerator [YourGenerator] -h

answered Apr 27, 2021 at 22:45

Sayyed Dawood's user avatar

2

  1. VS2019 [5.0].

  2. Update NuGet Packages (Tools -> Nuget Package Manager -> Manage
    NuGet packages for solution -> Click on the Updates tab, select all
    and run update.

  3. Solution -> Clean

  4. solution -> Build

  5. create a Controller.

I try everything but the above method work for me

answered Jan 2, 2021 at 17:55

nitin shinde's user avatar

I encountered this issue with net5.0, specifically against version 5.0.5 of some dependencies. I downgraded my nuget packages from 5.0.5 to 5.0.4 for these:

"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="5.0.4"
"Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.4"
"Microsoft.AspNetCore.Identity.UI" Version="5.0.4" 
"Microsoft.EntityFrameworkCore.Tools" Version="5.0.4"

Dharman's user avatar

Dharman

29.3k21 gold badges80 silver badges131 bronze badges

answered Apr 12, 2021 at 12:15

wazdev's user avatar

wazdevwazdev

3234 silver badges11 bronze badges

4

I just recently ran into the same issue.

I resolved it by eventually taking a look at each individual .csproj files included in my solution and fixing all the versions of the microsoft libraries that were included.

I changed the metapackage that i was referencing from «Microsoft.AspNetCore.All» to «Microsoft.AspNetCore.App», i then loaded up the reference list on nuget for the «App» package and removed any references to libraries that are already included in the metapackage.

I then made sure that i fixed the versions of any outstanding packages to match the version of the metapackage that the project automatically chooses ie in my case 2.2.0.

Something that tripped me up was that if you have multiple projects included in your solution you need to make sure that they reference the same metapackage as if there is a version mismatch between projects included in your solution you will get this issue too.

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.2.5" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
  </ItemGroup>

Changed to this.

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />
  </ItemGroup>

answered Jun 26, 2019 at 11:05

Darryn Hosking's user avatar

Darryn HoskingDarryn Hosking

2,9982 gold badges18 silver badges20 bronze badges

2

I just had this problem whilst adding a controller to a Core API with Entity Framework project. I’m using VS 16.8.5 with the most recent EF core, version 5.03. The class containing my DBContext class referenced EF 5.03 .

I (eventually!) noticed whilst browsing Nuget that the various code generation packages (none of which were referenced in my .csproj file, I think because ASP.Net core ships as a framework since 3.0 but correct me if I am wrong someone!), and in particular Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCode were 5.02. I didn’t touch my ASP.Net project, instead I dowgraded the other EF projects to 5.02 and it solved the problem.

answered Feb 16, 2021 at 17:48

Peter's user avatar

PeterPeter

618 bronze badges

I had resolved it by update two files

Microsoft.VisualStudio.Web.CodeGeneration
and
Microsoft.VisualStudio.Web.CodeGeneration.Design

. Its version should be match with other packages version in application.

answered Jul 10, 2020 at 13:38

Trident's user avatar

TridentTrident

311 silver badge9 bronze badges

Just update the NUGET packages from the Nuget Package Manager.

answered Aug 24, 2020 at 11:42

Mamoon Rasheed's user avatar

i have same error. and Update NuGet Packages (Tools -> Nuget Package Manager -> Manage NuGet packages for solution -> Click on installed.
You need select Version with notice Dependencies.

Example my option is fine with:

Microsoft.AspNetCore.Identity.EntityFramework Core with version 3.1.12

Microsoft.EntityFrameworkCore.Tools with version 3.1.12

Microsoft.EntityFrameworkCore.SqlServer with version 3.1.12

Microsoft.VisualStudio.Web.CodeGeneration.Design with version 3.1.5

answered Feb 27, 2021 at 18:00

ToanTV's user avatar

ToanTVToanTV

1111 silver badge3 bronze badges

1

I had the problem with a blazor server application version 5.0.5 and Microsoft Identity scaffolding. The highest available version of the CodeGeneration.Design package was 5.0.2, so i downgraded the other Microsoft packages (specially EntityFramework) to 5.0.2 and it solved the problem.

answered Apr 17, 2021 at 21:46

Andi's user avatar

AndiAndi

212 bronze badges

2

Had exactly same problem, in my situation CodeGenerator was missing

I have added this item into ItemGroup in .csproj

<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />

answered Jul 5, 2019 at 11:21

Whistler's user avatar

WhistlerWhistler

1,8374 gold badges27 silver badges50 bronze badges

What fixed it for me after I couldn’t scaffold IdentityFramework was by

  1. Checking VS2019 for updates.
  2. Update NuGet Packages (Tools -> Nuget Package Manager -> Manage NuGet packages for solution -> Click on the updates tab, select all and run update.
  3. Retry scaffolding identity

answered Jun 28, 2020 at 13:27

Joshua Tromp's user avatar

Cleaning the solution showed me an error of NuGet packages needed to be updated! I updated them and build the solution. Build Successful and I was able to create the controller class.

answered May 25, 2021 at 7:11

joekevinrayan96's user avatar

Trying to add MVC controller with views using EF for MVC project using Net5.0.

Using the following NuGet packages specific versions worked for me, while the problem was solved by using less version than the version of Microsoft.EntityFrameworkCore, for both Microsoft.EntityFrameworkCore.SqlServer and Microsoft.EntityFrameworkCore.Tools, these packages are referenced in the MVC project.

The correct packages are:

<ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="5.0.7" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.7" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.6" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.6">
           <PrivateAssets>all</PrivateAssets>
           <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
            </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.7" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />   
</ItemGroup>

answered Jun 18, 2021 at 1:39

Ashraf Sada's user avatar

Ashraf SadaAshraf Sada

4,4012 gold badges44 silver badges46 bronze badges

I also faced this same error when i was trying to scaffold identity template. I resolve this issue by updating nuget packages of the two major project of concerns(I mean the the two projects that has something to do with what i was to implement).

answered Jul 30, 2021 at 13:16

sammy Akinsoju's user avatar

I am also facing this issue.

Please follow this step,

  • Clean Your Solution
  • Open Nuget Manager
  • Check this version Microsoft.EntityFrameworkCore (I am using 5.0.8)
  • Check this version Microsoft.EntityFrameworkCore.Design (I am using 5.0.8)
  • Check this version Microsoft.EntityFrameworkCore.Tools (I am using 5.0.8)
  • Check this version Microsoft.EntityFrameworkCore.SqlServer (I am using 5.0.8)
  • Check this version Microsoft.VisualStudio.Web.CodeGeneration.Design (I am using 5.0.2)

Check this image also

  • After that Rebuild your solution and Create Scaffolding Controller

answered Aug 14, 2021 at 10:59

Abdulla Sirajudeen's user avatar

1

The problem is that you have some of the older versions of nuget pacakges installed in your project and when you try to scaffold the Asp.net core tries to install the latest packages which are required for scaffolding at this point Asp.net core throws such exception.

I suggest you to update your nuget packages and than try scafolding.

Wai Ha Lee's user avatar

Wai Ha Lee

8,41977 gold badges60 silver badges90 bronze badges

answered Sep 23, 2020 at 13:32

Mohammed Rehan Javed Abdul Kar's user avatar

I know that some of you might still facing the same issue,
I just did the next in VS 2022,

1- Checked the depencendies on the current project.
enter image description here

2- Remove all of them

3- Go to dependencies
add a lower version

enter image description here

and the clean the solution and add the views.

answered Aug 15, 2022 at 19:14

Jose Antonio's user avatar

1

I also faced the same issue, Here is How I solved the Issue

There was an error running the selected code generation, ‘Package restore failed. Rolling back package canges for web’

1— Check if your Solution has multiple projects, please check their Target Dot.net Framework.(in my case it was .Net Standard 1.6 for class libraries & .NetCoreApp 1.0 for Web Project, I changed it to .NetCoreApp 1.1)

2— After having the same framework, clean the web project, Rebuilt and Add new Controller.

If its successful fine otherwise You might encounter another error e.g

‘There was an error running the code generator: ‘No executable found matching command «dotnet-aspnet-codegenerator»‘

If you have project.json file open it other wise open .csproj.user project in note pad, please add following


Please note based on your .net version you might have different version no.

You may find instruction in ScaffoldingReadMe.txt file if its generated in your project

answered Aug 17, 2017 at 4:12

Aamir's user avatar

AamirAamir

68510 silver badges11 bronze badges

All I had to do was open the properties of my web project and change the TargetFramework from 2.1 to 2.2. Or to match whatever version of the framework your business and object layer are using.

answered May 30, 2019 at 14:22

BBoyd's user avatar

BBoydBBoyd

411 bronze badge

Had the same problem, but updating all the NuGet Packages has solved the problem.
Right click on <your project name> file -> Manage NuGet Packages -> Updates -> Select all packages -> Update

answered Apr 27, 2020 at 9:13

Maksym Voloshko's user avatar

I’m running .NET Core (and Entity Framework Core) 3.1.x.

I got this exact error and tried updating all the nuget packages and other relevant solutions already mentioned in the answers here.

The issue was simply that my database server was not running (it runs on a local VM). In other words, my database context (i.e. ApplicationDbContext) mentioned in the ‘Add Controller…’ window, was not able to access the db. Once I started the db server, my scaffolding created without issue.

Keep also in mind, the model/class (i.e. table) that the controller and views were referencing had not been created yet (I hadn’t run add-migration yet). So, it just needed the db connection only.

It’s kind of a silly (obvious?) solution, but very misleading when looking at the ‘Package Restore Failed’ error message.

answered Jun 9, 2020 at 15:56

Sum None's user avatar

Sum NoneSum None

2,0032 gold badges23 silver badges31 bronze badges

I had a similar issue with entity framework core sqlite nuget packages. I installed sqlite and sqlite core packages fixed this. Probably a needy package is missing. Also make sure SQL Server and Server Agent are running. Check those on SQL Server Configuration > SQL Server Services > Right click on SQL Server or Server Agent and start the service then restart the server. Guess this might help someone

answered Aug 11, 2020 at 7:32

FF new's user avatar

FF newFF new

1031 gold badge1 silver badge11 bronze badges

My solution
-Vs2019 all nuget packages upgrade

answered Sep 21, 2020 at 21:21

wasdoska's user avatar

As someone mentioned earlier, I updated all NuGet packages from Tools->Nuget Package Manager -> Manage NuGet Packages for Solution -> Updates tab -> Update All. I was then able to add a controller with EF and have VS generate the associated views.

answered Oct 13, 2020 at 13:40

Phillip's user avatar

Just update all Nuget Packages , Clean Solution and the rebuild solution. It solve the issues for me.

answered Jan 30, 2021 at 15:26

vsharma10286's user avatar

I just updated EntityFrameworkCore from Version 3.1.10 to 3.1.13 and it solved the problem. My Project file looks like:

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

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.13" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.13" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.13" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.13">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.5" />
  </ItemGroup>

</Project>

answered May 3, 2021 at 6:59

Rahim's user avatar

RahimRahim

7896 silver badges6 bronze badges

I had this same issue when creating a new ‘Identity’ scaffolded item.
I managed to get this working by removing everything within the <ItemGroup> tags within the csproj file and running the code generator. The generator then installs packages that it needs.

answered May 22, 2021 at 10:27

Hannah's user avatar

HannahHannah

3215 silver badges8 bronze badges

In case you are using .net 5.0.14, downgrading every packages with version 5.0.14 from 5.0.14 to 5.0.12 fixed the problem for me.

answered Mar 10, 2022 at 7:15

KodFun's user avatar

KodFunKodFun

3033 silver badges8 bronze badges

Уведомления

  • Начало
  • » GUI
  • » Qt Designer. Ошибка генерации кода

#1 Ноя. 5, 2011 17:40:06

Qt Designer. Ошибка генерации кода

Помогите, при выборе “Показать код” возникает такая ошибка, в чем дело?

Отредактировано (Ноя. 5, 2011 17:42:56)

Офлайн

  • Пожаловаться

#2 Ноя. 19, 2011 11:14:00

Qt Designer. Ошибка генерации кода

У меня тоже самое.
Помогите пожалуста ;(

Офлайн

  • Пожаловаться

#3 Ноя. 20, 2011 11:11:12

Qt Designer. Ошибка генерации кода

Первое: а тот ли у тебя питон стоит, 2.7?
Второе: а правильно ли к нему путь задан?
Третье: обрати особое внимание на разные слэши /PyQt4uic. Если путь задан в настройках, то исправь слэши на виндовый
Четвертое: в любых вопросах про питон необходимо указать
Операционную систему
Версию питона

Офлайн

  • Пожаловаться

#4 Окт. 13, 2012 14:42:29

Qt Designer. Ошибка генерации кода

Jazzis
Помогите, при выборе “Показать код” возникает такая ошибка, в чем дело?

Чем решилось? У меня такая же проблема.

Офлайн

  • Пожаловаться

#5 Окт. 13, 2012 15:48:46

Qt Designer. Ошибка генерации кода

alexisgeorge
Чем решилось? У меня такая же проблема.

Нужно вручную запускать pyuic4.bat из Python27Libsite-packagesPyQt4pyuic4.bat с параметрами.

Офлайн

  • Пожаловаться

#6 Окт. 22, 2012 09:16:32

Qt Designer. Ошибка генерации кода

Я делал как описано тут

—————————————————————–
Изучаю и параллельно использую Python 2.7

Офлайн

  • Пожаловаться

  • Начало
  • » GUI
  • » Qt Designer. Ошибка генерации кода

Понравилась статья? Поделить с друзьями:
  • Ошибка графический интерфейс системы андроид как исправить
  • Ошибка генерации изображения drupal 7
  • Ошибка графический драйвер amd не установлен или функционирует неправильно windows 10
  • Ошибка данных при создании профиля mafia 2
  • Ошибка генератора порше кайен 958