1
Good morning!
When performing the add-Migration command, to make the migrations, I am receiving the error sequinte:
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"
}
} }
Error says basepath is empty, but it is not I still don’t have the bank connections, because it will be online and have not passed the information, can that be the problem? I find it strange pq to do the Migrations, I think I do not need a bank (I think)
Managed to solve this problem?
– Danilo Pádua