Error using the add-migration command. Using json as configuration file

1

Good morning!

When I run the add-migration command, to do the migrations, I'm getting the following error:

Add-Migration : Exception calling "AddFromFile" with "1" argument(s) : "'basePath' 
        não pode ser uma cadeia de caracteres vazia("") nem começar com o caractere nulo.
        Nome do parâmetro: basePath"At line:1 char:1
        + add-migration Initial
        + ~~~~~~~~~~~~~~~~~~~~~
         + CategoryInfo          : NotSpecified: (:) [Add-Migration], MethodInvocationE
            xception
            + FullyQualifiedErrorId : ArgumentException,Add-Migration

My context class

protected override void OnModelCreating(ModelBuilder modelBuilder)
    {

        ////////////////////////// MAPEAMENTOS ////////////////////////
        #region FluentAPI

        #region Barcos

        modelBuilder.Entity<Barco>()
           .ToTable("Barcos");

        modelBuilder.Entity<Barco>()
            .Property(e => e.Nome)
            .HasColumnType("varchar(150)")
            .IsRequired();

        modelBuilder.Entity<Barco>()
            .Property(e => e.CapacidadeAgua)
            .HasColumnType("varchar(50)")
            .IsRequired();

        modelBuilder.Entity<Barco>()
             .Property(e => e.CapacidadeOleo)
             .HasColumnType("varchar(50)")
             .IsRequired();

        modelBuilder.Entity<Barco>()
             .Property(e => e.SapId)
             .HasColumnType("varchar(10)")
             .IsRequired();

        modelBuilder.Entity<Barco>()
            .Ignore(b => b.ValidationResult);

        modelBuilder.Entity<Barco>()
            .Ignore(b => b.CascadeMode);

        modelBuilder.Entity<Barco>()
           .HasOne(b => b.CategoriaBarco)
           .WithMany(c => c.Barcos)
           .HasForeignKey(b => b.CategoriaBarcoID)
           .IsRequired();

        modelBuilder.Entity<Barco>()
            .HasOne(b => b.TipoOperacao)
            .WithMany(b => b.barcos)
            .HasForeignKey(b => b.TipoOperacaoID)
            .IsRequired();






        #endregion

        ////////////////////////// FIM MAPEAMENTO BARCOS////////////////////////

        #region CategoriaBarco

        modelBuilder.Entity<CategoriaBarco>()
           .ToTable("CategoriaBarco");

        modelBuilder.Entity<Barco>()
        .Ignore(b => b.ValidationResult);

        modelBuilder.Entity<Barco>()
            .Ignore(b => b.CascadeMode);


        #endregion


        #region TipoOperação

        modelBuilder.Entity<TipoOperacao>()
           .ToTable("TipoOperacao");

        modelBuilder.Entity<Barco>()
        .Ignore(b => b.ValidationResult);

        modelBuilder.Entity<Barco>()
            .Ignore(b => b.CascadeMode);



        #endregion

        #endregion


        base.OnModelCreating(modelBuilder);

    }


    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {

        var config = new ConfigurationBuilder()
            .SetBasePath(Directory.GetCurrentDirectory())
            .AddJsonFile("appsettings.json")
            .Build();

        optionsBuilder.UseOracle(config.GetConnectionString("DefaultConnection"));


    }





}

}

My json file:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=YOURSERVERNAME;   Database=YOURDATABASENAME; Trusted_Connection=True; MultipleActiveResultSets=true"

},

 "Logging": {
   "IncludeScopes": false,
     "LogLevel": {
     Default": "Debug",
      "System": "Information",
         "Microsoft": "Information"
}

} }

The error says that the basepath is empty, but it is not I still do not have the bank connections, because it will be online and have not passed the information yet, can that be the problem? I find strange why to do the migrations, I do not think I need a bank (I think)

    
asked by anonymous 25.07.2018 / 16:24

1 answer

0

Check the structure of your project in Properties > Application:

Thenverifythatthisversionisinstalledonyourcomputer:

C:/ProgramFiles/dotnet/shared/Microsoft.NETCore.App

    
17.08.2018 / 19:43