简体   繁体   中英

Asp.Net Core How to Configure Migrations type to assembly

Hello everyone my name is Taniguchi and i learning asp.net core and I managed to create a migration but when I used the Update-Database command show me the following error: "

Specify the '-Verbose' flag to view the SQL statements being applied to the target database. No migrations configuration type was found in the assembly 'WebApplication1'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration).

my database:

 public class MimicContext : DbContext
{
    public MimicContext(DbContextOptions<MimicContext> options) : base(options)
    {

    }

    public DbSet<Palavra> Palavras { get; set; }
}

my startup:

public class Startup
{
    // This method gets called by the runtime. Use this method to add services to the container.
    // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
    public void ConfigureServices(IServiceCollection services)
    {

        services.AddDbContext<MimicContext>(opt =>
        {
            opt.UseSqlite("Data Source=Database\\Mimic.db");
        });

        services.AddMvc(options => options.EnableEndpointRouting = false);
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

       

        app.UseMvc();
    }
}

How can i configure a migration to the assembly ?

Have you enabled migrations in your project? If you didn't than use Enable-Migrations. I think that it could be the problem.

Before running the update command in PMC first enable it. For more details view this link here

Small mistake, but good learning for me after spending more than one day painful effort. I hope this will be the good learning for others too.

I have added two NuGet packages of: EntityFramework, and Microsoft.EntityFrameworkCore which is my mistake.

Just adding NuGet package for Microsoft.EntityFrameworkCore will do all the required work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM