Empty formatted output string for connection debug log
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
After upgrade to EF Core 7/.NET 7.0, running a simple db app with debug logging, I noticed the following that the disposed log message does not contain any values, just empty placeholders. The log entry just above still contains the values.
```ini
dbug: Microsoft.EntityFrameworkCore.Infrastructure[10407]
'MyContext' disposed.
dbug: Microsoft.EntityFrameworkCore.Database.Connection[20007]
Disposing connection to database 'Repro' on server 'localhost'.
dbug: Microsoft.EntityFrameworkCore.Database.Connection[20008]
Disposed connection to database '' on server '' (1ms).
```
Repro:
```csharp
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
const string connectionString = "Data Source=localhost;Initial Catalog=Repro;TrustServerCertificate=True;Integrated Security=True;";
var builder = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
services.AddLogging();
services.AddDbContext(a => a.UseSqlServer(connectionString));
})
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.AddConsole();
logging.SetMinimumLevel(LogLevel.Debug);
});
using var host = builder.Build();
await host.StartAsync();
await using var context = host.Services.GetRequiredService();
await context.Database.EnsureCreatedAsync().ConfigureAwait(false);
await context.DisposeAsync().ConfigureAwait(false);
await host.StopAsync();
Console.ReadLine();
public class MyContext : DbContext
{
public MyContext(DbContextOptions options) : base(options)
{
}
}
```
### Include provider and version information
EF Core version: 7.0.0
Database provider:: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 7
Operating system: Win11
IDE: VS 17.4
Contributor guide
Assessment
This issue has not been assessed yet.