[Fix] There Was An Error Running The Selected Code Generator

Published & Fact Checked by
Published on:

Ai Disclaimer: We don't use AI for content or research. The contents is researched and written by our team.

» Home » Error Codes » Softwares » [Fix] There Was An Error Running The Selected Code Generator

If you are on a Visual Studio platform program and are working to create an ASP.net project. Then, from time to time, you might come across the following “There was an error running the selected code generator” error message. 

There Was An Error Running The Selected Code Generator

Now, there can be a number of reasons behind the particular error to occur. It might come up as a result of an outdated version of the VS app, an issue with compatibility between your .NET framework and your VS application, or a corrupt file somewhere. 

Hence, to deal with the following issue, we had done our own research and after doing an extensive survey on various forums and threads online, we have managed to found a few solutions as shown below:


Fixes For “There was an error running the selected code generator”


Fix 1: Restart VS

There Was An Error Running The Selected Code Generator

Sometimes, just a simple restart may be all that is needed to solve an error. 

Although, I am pretty sure by now, you must have surely tried restarting the app once by now. However, if not, try to restart the program and see if that does the trick for you as it did for the user @Sajithd above.


Fix 2: Update Visual Studio

If you doubt that you have a very old version of VS and that might be adding up to the reason for the following error to show up. Then, it would be a good idea to update your VS software as soon as possible to see if doing so helps fix the error.

There Was An Error Running The Selected Code Generator

Fix 3: Clean solution

Another easy way with the help of which you could try solving the error would be to try out the clean solution option from build within VS, as mentioned by @users3416682 below.

There Was An Error Running The Selected Code Generator

Fix 4: Rebuild Solution

This is one of the simplest solutions after restarting your VS. 

All you need to do here is that once your VS has been restarted. Go to your Solution Explorer, and choose the Rebuild solution option from the drop down menu list after right-clicking on it.

There Was An Error Running The Selected Code Generator

Fix 5: Delete Cache files

There Was An Error Running The Selected Code Generator

There may be times when certain stored data in your cache memory might come in conflict and cause such errors to occur as a result. 

In such cases, it would be a good idea to try clearing such cache data from your system to see if that helps deal with the particular error as have been mentioned above by user @Longday.


Fix 6: Try adding new item

You can also try adding a new item to your list to your project. Although, I’m not sure how this works. Still, you can give this method a try and it might work for you, as it did for the user @Maksym Labutin as shown below.

There Was An Error Running The Selected Code Generator

Fix 7: Bypass with Razor

Although, this is not a complete fix to the following error. Still, it can work as a bypass or alternative to add the view option to your project, without having to deal with the error.

You can follow the steps as have been mentioned below, and see if that helps with the error in any way. 

There Was An Error Running The Selected Code Generator

Fix 8: Switch to a compatible version

As had been mentioned above. Most often the reason why you would see the following error would be due to an outdated version of the program or an incompatible version.

To solve this, you will need to either update the application or install the version manually with the help of Nuget package manager as shown below.

There Was An Error Running The Selected Code Generator
There Was An Error Running The Selected Code Generator

Fix 9: Add controller via scaffolding

This approach is a little out of the box and involves creating a controller via scaffolding. 

Here, if you do not see the scaffolding option on your VS platform. Then, you can easily add it with the help of an extension for VS. 

Once the extension has been added. You can next, follow the instructions as mentioned by @erikrunia shown below.

There Was An Error Running The Selected Code Generator

Fix 10: Check and replace .Net version

If your projects are not running on the same .Net versions. Then too, you might get prompted with such an error. 

Hence, it is very important that you check all your projects as well as which version of Entity Framework they are running on. And, if a project is running on a different version. Then, set the target framework to your desired one over at the Application menu option as shown below and rebuild your solution. 

Check if following the steps as mentioned by @RitchieD helps to solve the error in your case as well. 

There Was An Error Running The Selected Code Generator

The following solution, as have been mentioned by a user named @tHeSiD is a little lengthy. However, if none of the solutions as have been mentioned above work for you. Then, you can give this method a try too and see if it helps deal with the following error. 

Basically, what you will need to do here in the following solution, is check all your package versions manually. And then, manually go on editing the versions to the desired one or the most recent version.

Once that is done. Next, simply delete a few packages and folder as shown by @tHeSiD below and check if it helps solve the error on your systems as well. 

There Was An Error Running The Selected Code Generator
There Was An Error Running The Selected Code Generator
There Was An Error Running The Selected Code Generator

Like This Post? Checkout More

Photo of author
Rishikesh Hazarika is a tech enthusiast who is always curious to learn and absorb facts and data in the world of science and technology as well as tries to share his opinion. He has an M.Tech degree from North-Eastern Hill University, later he did a certificate course in Computer Hardware and Software, and a certificate course in Introduction to Architectingc