I am trying to update a database in .NET Core using the command
dotnet ef database update
but I am getting the following error
Error Number:18456,State:1,Class:14
Login failed for user ''.
I can log in in my SQL Server with this User ID and password so I don´t think the problem is in my connection string
Context
public class CommanderContext : DbContext
{
public CommanderContext(DbContextOptions<CommanderContext> opt) : base(opt)
{
}
public DbSet<Command> Commands { get; set; }
}
}
appsettings.cs
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"CommanderConnection": "Server=localhost;Initial Catalog=CommanderDB,User ID=CommanderApi;Password=*****;"
}
}
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages();
services.AddDbContext<CommanderContext>(opt => opt.UseSqlServer(Configuration.GetConnectionString("CommanderConnection")));
services.AddControllers();
services.AddScoped<ICommanderRepo, MockCommanderRepo>();
}
I also leave a print of my SQL Server

Login failed for userand your statement "I don´t think the problem is in my connection string" - the update statement may not be seeing the connection string or the string has errors.