Rafael Gómez
Rafael Gómez

Reputation: 1

There was an error running the selectd code generator: "There was an error creating a DbContext"

I am trying to build an API with Visual Studio Community using the ASP .NET CORE Web Api project template. Crating the scaffolding of the model created:

public class Game
{
    public int Id { get; set; }

    public string Name { get; set; }
}

I am having an error creating the scaffolding item called "Api controller with actions, using Entity Framework"

enter image description here

This is my program.cs (I have not touched anything of it):

internal class Program
{
    private static void Main (string[] args)
    {
        var builder = WebApplication.CreateBuilder(args);

        // Add services to the container.

        builder.Services.AddControllers();
        // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
        builder.Services.AddEndpointsApiExplorer();
        builder.Services.AddSwaggerGen();

        var app = builder.Build();

        // Configure the HTTP request pipeline.
        if (app.Environment.IsDevelopment())
        {
            app.UseSwagger();
            app.UseSwaggerUI();
        }

        app.UseHttpsRedirection();

        app.UseAuthorization();

        app.MapControllers();

        app.Run();
    }
}

And this are my packages installed:

enter image description here

The only thing I did was create the model and trying to do the scaffold.

I have tried to do it in .NET 6, 7 and 8. And I have the same problem.

Upvotes: 0

Views: 66

Answers (0)

Related Questions