Migration does not run on EF Core 2.0

Asked

Viewed 41 times

0

When Perform Add-Migration Init no message is shown and Migration is not performed and the prompt is in the state again PM>

I checked that you are taking Entityframeworkcore.Tools 2.0.3 instead of 2.1.3 which is the nuget DLL that is the reference

C:\Program Files\dotnet\dotnet.exe exec --depsfile C:\Users\nicoucc\source\AberturaDeContas\apl-back-core-acd\Safra.AberturaDeContas.Repositories\bin\Debug\netcoreapp2.1\Safra.AberturaDeContas.Repositories.deps.json --additionalprobingpath C:\Users\nicoucc.nuget\packages --additionalprobingpath "C:\Program Files\dotnet\sdk\NuGetFallbackFolder" --runtimeconfig C:\Users\nicoucc\source\AberturaDeContas\apl-back-core-acd\Safra.AberturaDeContas.Repositories\bin\Debug\netcoreapp2.1\Safra.AberturaDeContas.Repositories.runtimeconfig.json C:Users nicoucc.nuget Packages microsoft.entityframeworkcore.tools 2.0.3 tools netcoreapp2.0 Ef.dll Migrations add Test --json --verbose --no-color --prefix-output --Assembly C: Users nicoucc source Openback-core-Acd Safra.AbertureDeContas.Repositories bin Debug netcoreapp2.1 Safra.AbertureDeContas.Repositories.dll --startup-Assembly C: Users nicoucc source Aberturadecontas apl--back-core-acd\Safra.AberturaDeContas.Repositories\bin\Debug\netcoreapp2.1\Safra.AberturaDeContas.Repositories.dll --project-dir C:\Users\nicoucc\source\AberturaDeContas\apl-back-core-acd\Safra.AberturaDeContas.Repositories\ --root-namespace Safra.AberturaDeContas.Repositories

Context class

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

    }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {            
        base.OnConfiguring(optionsBuilder);
    }

    public DbSet<Teste> Testes { get; set; }

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

Facotry Context class

public class MyContextFactory : IDesignTimeDbContextFactory<MyContext>
{
    public MyContext CreateDbContext(string[] args)
    {
        var optionsBuilder = new DbContextOptionsBuilder<MyContext>();
        
        optionsBuilder.UseSqlServer(
            @"Data Source=3Y1S0L2\SQLEXPRESS;Initial Catalog=AberturaDeContas;User ID=sa;Password=abc102030!;"
        );

        return new MyContext(optionsBuilder.Options);
    }
}

Entity class

public class Teste
{
    public int Id { get; set; }
    public string Nome{ get; set; }
}
  • run Add-Migration -verbose to see what is running

  • See if you can take a look at the issue I made friend

  • @Nicolabogar try to run straight into the terminal, dotnet ef migrations add %nome%, another point, using EF Core 2.1 or 2.0? in 2.1 Tooling is already in the SDK, so please uninstall Dotnetclitoolreference.

  • I am using 2.1, this DLL you are talking about is not even referenced in my repository DLL. Apparently by CMD is going normal

  • As far as I can see, Migration is not able to write the error that it gives in some file to show to me in VS2017, because what reason will it be ? At the prompt appears the error correctly

  • @Tobiasmsearch as I run Update-Database by the same prompt I run Migration ?

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.