1
resposta

DbContext was found in assembly - Migration

Quando executo o Migration ocorre esse erro

No DbContext was found in assembly 'CasaDoCodigo'. Ensure that you're using the correct assembly and that the type is neither abstract nor generic.

***Todos as extensões instaladas estão na versão 2.0.0

CLASSE CONTEXTO

public class ApplicationContext : DbContext
    {

        public ApplicationContext(DbContextOptions options) : base(options)
        {

        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Entity<Produto>().HasKey(p => p.Id);
        }

    }

CLASSE STARTUP

string connectionString = Configuration.GetConnectionString("ConexaoDB");
            services.AddDbContext<ApplicationContext>(x => x.UseSqlServer(connectionString));

CONNECTION

"ConnectionStrings": {
    "ConexaoDB": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=CasaDoCodigo;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"

  }

EXTENSÕES

Microsoft.AspNetCore.All 2.0.0
Microsoft.EntityFrameworkCore 2.0.0
Microsoft.EntityFrameworkCore.Design 2.0.0
Microsoft.EntityFrameworkCore.SqlServer 2.0.0
Microsoft.EntityFrameworkCore.Tools 2.0.0
1 resposta

Olá Matheus, tudo bem?

Tem como compartilhar seu código via Dropbox, Google Drive ou Github, para que eu possa dar uma olhada?

No aguardo!