Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions build/dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@
<NpgsqlVersion60>6.0.13</NpgsqlVersion60>
<NpgsqlVersion70>7.0.10</NpgsqlVersion70>
<NpgsqlVersion80>8.0.7</NpgsqlVersion80>
<NpgsqlVersion90>9.0.3</NpgsqlVersion90>
<NpgsqlVersion90>9.0.4</NpgsqlVersion90>
<NpgsqlVersion100>10.0.0</NpgsqlVersion100>

<MicrosoftDataSqlClientVersion60>5.2.2</MicrosoftDataSqlClientVersion60>
<MicrosoftDataSqlClientVersion70>5.2.2</MicrosoftDataSqlClientVersion70>
<MicrosoftDataSqlClientVersion80>5.2.2</MicrosoftDataSqlClientVersion80>
<MicrosoftDataSqlClientVersion90>5.2.2</MicrosoftDataSqlClientVersion90>
<MicrosoftDataSqlClientVersion100>5.2.2</MicrosoftDataSqlClientVersion100>

<NpgsqlEntityFrameworkCorePostgreSQLVersion60>6.0.29</NpgsqlEntityFrameworkCorePostgreSQLVersion60>
<NpgsqlEntityFrameworkCorePostgreSQLVersion70>7.0.18</NpgsqlEntityFrameworkCorePostgreSQLVersion70>
<NpgsqlEntityFrameworkCorePostgreSQLVersion80>8.0.11</NpgsqlEntityFrameworkCorePostgreSQLVersion80>
<NpgsqlEntityFrameworkCorePostgreSQLVersion90>9.0.4</NpgsqlEntityFrameworkCorePostgreSQLVersion90>

<PomeloEntityFrameworkCoreMySqlVersion60>6.0.3</PomeloEntityFrameworkCoreMySqlVersion60>
<PomeloEntityFrameworkCoreMySqlVersion70>7.0.0</PomeloEntityFrameworkCoreMySqlVersion70>
<PomeloEntityFrameworkCoreMySqlVersion80>8.0.2</PomeloEntityFrameworkCoreMySqlVersion80>
<PomeloEntityFrameworkCoreMySqlVersion90>8.0.2</PomeloEntityFrameworkCoreMySqlVersion90>
<NpgsqlEntityFrameworkCorePostgreSQLVersion100>10.0.0</NpgsqlEntityFrameworkCorePostgreSQLVersion100>

<MicrosoftEntityFrameworkCoreSqlServerVersion60>6.0.35</MicrosoftEntityFrameworkCoreSqlServerVersion60>
<MicrosoftEntityFrameworkCoreSqlServerVersion70>7.0.20</MicrosoftEntityFrameworkCoreSqlServerVersion70>
<MicrosoftEntityFrameworkCoreSqlServerVersion80>8.0.10</MicrosoftEntityFrameworkCoreSqlServerVersion80>
<MicrosoftEntityFrameworkCoreSqlServerVersion90>9.0.0-rc.2.24474.1</MicrosoftEntityFrameworkCoreSqlServerVersion90>
<MicrosoftEntityFrameworkCoreSqlServerVersion90>9.0.11</MicrosoftEntityFrameworkCoreSqlServerVersion90>
<MicrosoftEntityFrameworkCoreSqlServerVersion100>10.0.1</MicrosoftEntityFrameworkCoreSqlServerVersion100>

<MicrosoftEntityFrameworkCoreSqliteVersion60>6.0.35</MicrosoftEntityFrameworkCoreSqliteVersion60>
<MicrosoftEntityFrameworkCoreSqliteVersion70>7.0.20</MicrosoftEntityFrameworkCoreSqliteVersion70>
<MicrosoftEntityFrameworkCoreSqliteVersion80>8.0.10</MicrosoftEntityFrameworkCoreSqliteVersion80>
<MicrosoftEntityFrameworkCoreSqliteVersion90>9.0.0-rc.2.24474.1</MicrosoftEntityFrameworkCoreSqliteVersion90>
<MicrosoftEntityFrameworkCoreSqliteVersion90>9.0.11</MicrosoftEntityFrameworkCoreSqliteVersion90>
<MicrosoftEntityFrameworkCoreSqliteVersion100>10.0.1</MicrosoftEntityFrameworkCoreSqliteVersion100>

<!--
Don't follow ASPNETCORE version for this package since it only exists as servicing builds
Expand All @@ -40,6 +40,7 @@
<MicrosoftIISTestingVersion80>8.0.0-*</MicrosoftIISTestingVersion80>
<MicrosoftIISTestingVersion90>9.0.0-*</MicrosoftIISTestingVersion90>
<MicrosoftIISTestingVersion100>10.0.0-*</MicrosoftIISTestingVersion100>
<MicrosoftIISTestingVersion110>11.0.0-*</MicrosoftIISTestingVersion110>

<DapperVersion>2.1.66</DapperVersion>
<DapperAotVersion>1.0.48</DapperAotVersion>
Expand Down
11 changes: 10 additions & 1 deletion src/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<PackageReference Include="Microsoft.AspNetCore.Server.IntegrationTesting.IIS" Version="$(MicrosoftIISTestingVersion80)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0' or '$(TargetFramework)' == 'net10.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(NpgsqlEntityFrameworkCorePostgreSQLVersion90)" />
<PackageReference Include="Npgsql" Version="$(NpgsqlVersion90)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="$(MicrosoftEntityFrameworkCoreSqlServerVersion90)" />
Expand All @@ -66,6 +66,15 @@
<PackageReference Include="Microsoft.AspNetCore.Server.IntegrationTesting.IIS" Version="$(MicrosoftIISTestingVersion90)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net10.0' or '$(TargetFramework)' == 'net11.0'">
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(NpgsqlEntityFrameworkCorePostgreSQLVersion100)" />
<PackageReference Include="Npgsql" Version="$(NpgsqlVersion100)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="$(MicrosoftEntityFrameworkCoreSqlServerVersion100)" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="$(MicrosoftDataSqlClientVersion100)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="$(MicrosoftEntityFrameworkCoreSqliteVersion100)" />
<PackageReference Include="Microsoft.AspNetCore.Server.IntegrationTesting.IIS" Version="$(MicrosoftIISTestingVersion100)" />
</ItemGroup>
Comment on lines +69 to +76
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition groups net10.0 and net11.0 together, but net11.0 should use MicrosoftIISTestingVersion110 instead of MicrosoftIISTestingVersion100. Consider splitting this into two separate ItemGroup conditions: one for net10.0 using Version100 variables, and another for net11.0 using Version110 for Microsoft.AspNetCore.Server.IntegrationTesting.IIS (while other packages can continue using Version100 if no Version110 equivalents are defined).

Copilot uses AI. Check for mistakes.

<ItemGroup>
<PackageReference Include="RazorSlices" Version="$(RazorSlicesVersion)" />
</ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/Benchmarks/Data/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ namespace Benchmarks.Data
[Table("world")]
public class World
{
[UseColumnAttribute] // Fixes DAP043 warning
[Column("id")]
public int Id { get; set; }

[IgnoreDataMember]
[NotMapped, DbValue(Ignore = true)]
public int _Id { get; set; }

[UseColumnAttribute] // Fixes DAP043 warning
[Column("randomnumber")]
public int RandomNumber { get; set; }
}
Expand Down
166 changes: 86 additions & 80 deletions src/Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,100 +55,104 @@ public static void Main(string[] args)

Protocol = config["protocol"] ?? "";

var webHostBuilder = new WebHostBuilder()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseConfiguration(config)
.UseStartup<Startup>()
.ConfigureLogging(loggerFactory =>
var hostBuilder = new HostBuilder()
.ConfigureWebHost(webHostBuilder =>
{
if (Enum.TryParse(config["LogLevel"], out LogLevel logLevel))
{
Console.WriteLine($"Console Logging enabled with level '{logLevel}'");
loggerFactory.AddConsole().SetMinimumLevel(logLevel);
}
})
.ConfigureServices(services => services
.AddSingleton(new ConsoleArgs(args))
.AddSingleton<IScenariosConfiguration, ConsoleHostScenariosConfiguration>()
.AddSingleton<Scenarios>()
.Configure<LoggerFilterOptions>(options =>
webHostBuilder
.UseContentRoot(Directory.GetCurrentDirectory())
.UseConfiguration(config)
.ConfigureServices(services => services
.AddSingleton(new ConsoleArgs(args))
.AddSingleton<IScenariosConfiguration, ConsoleHostScenariosConfiguration>()
.AddSingleton<Scenarios>()
.Configure<LoggerFilterOptions>(options =>
{
if (Boolean.TryParse(config["DisableScopes"], out var disableScopes) && disableScopes)
{
Console.WriteLine($"LoggerFilterOptions.CaptureScopes = false");
options.CaptureScopes = false;
}
})
)
.UseStartup<Startup>()
.ConfigureLogging(loggerFactory =>
{
if (Enum.TryParse(config["LogLevel"], out LogLevel logLevel))
{
Console.WriteLine($"Console Logging enabled with level '{logLevel}'");
loggerFactory.AddConsole().SetMinimumLevel(logLevel);
}
})
.UseDefaultServiceProvider(
(context, options) => options.ValidateScopes = context.HostingEnvironment.IsDevelopment());

if (String.Equals(Server, "Kestrel", StringComparison.OrdinalIgnoreCase))
{
if (Boolean.TryParse(config["DisableScopes"], out var disableScopes) && disableScopes)
webHostBuilder.UseKestrel(options =>
{
Console.WriteLine($"LoggerFilterOptions.CaptureScopes = false");
options.CaptureScopes = false;
}
})
)
.UseDefaultServiceProvider(
(context, options) => options.ValidateScopes = context.HostingEnvironment.IsDevelopment());
var urls = config["urls"] ?? config["server.urls"];

if (!string.IsNullOrEmpty(urls))
{
foreach (var value in urls.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
{
Listen(options, config, value);
}
}
else
{
Listen(options, config, "http://localhost:5000/");
}
});

var threadCount = GetThreadCount(config);

webHostBuilder.UseSockets(socketOptions =>
{
if (threadCount > 0)
{
socketOptions.IOQueueCount = threadCount;
}

if (String.Equals(Server, "Kestrel", StringComparison.OrdinalIgnoreCase))
{
webHostBuilder = webHostBuilder.UseKestrel(options =>
{
var urls = config["urls"] ?? config["server.urls"];
Console.WriteLine($"Using Sockets with {socketOptions.IOQueueCount} threads");
});

if (!string.IsNullOrEmpty(urls))
webHostBuilder.UseSetting(WebHostDefaults.ServerUrlsKey, string.Empty);
}
else if (String.Equals(Server, "HttpSys", StringComparison.OrdinalIgnoreCase))
{
// Disable cross-platform warning
#pragma warning disable CA1416
webHostBuilder.UseHttpSys();
#pragma warning restore CA1416
}
else if (String.Equals(Server, "IISInProcess", StringComparison.OrdinalIgnoreCase))
{
foreach (var value in urls.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
#if NET9_0_OR_GREATER
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_IIS_VERSION")))
{
Listen(options, config, value);
throw new InvalidOperationException("Benchmark wants to use IIS but app isn't running in IIS.");
}
#endif
webHostBuilder.UseKestrel().UseIIS();
}
else
else if (String.Equals(Server, "IISOutOfProcess", StringComparison.OrdinalIgnoreCase))
{
Listen(options, config, "http://localhost:5000/");
#if NET9_0_OR_GREATER
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_IIS_VERSION")))
{
throw new InvalidOperationException("Benchmark wants to use IIS but app isn't running in IIS.");
}
#endif
webHostBuilder.UseKestrel().UseIISIntegration();
}
});

var threadCount = GetThreadCount(config);

webHostBuilder.UseSockets(socketOptions =>
{
if (threadCount > 0)
else
{
socketOptions.IOQueueCount = threadCount;
throw new InvalidOperationException($"Unknown server value: {Server}");
}

Console.WriteLine($"Using Sockets with {socketOptions.IOQueueCount} threads");
});

webHostBuilder.UseSetting(WebHostDefaults.ServerUrlsKey, string.Empty);
}
else if (String.Equals(Server, "HttpSys", StringComparison.OrdinalIgnoreCase))
{
// Disable cross-platform warning
#pragma warning disable CA1416
webHostBuilder = webHostBuilder.UseHttpSys();
#pragma warning restore CA1416
}
else if (String.Equals(Server, "IISInProcess", StringComparison.OrdinalIgnoreCase))
{
#if NET9_0_OR_GREATER
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_IIS_VERSION")))
{
throw new InvalidOperationException("Benchmark wants to use IIS but app isn't running in IIS.");
}
#endif
webHostBuilder = webHostBuilder.UseKestrel().UseIIS();
}
else if (String.Equals(Server, "IISOutOfProcess", StringComparison.OrdinalIgnoreCase))
{
#if NET9_0_OR_GREATER
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_IIS_VERSION")))
{
throw new InvalidOperationException("Benchmark wants to use IIS but app isn't running in IIS.");
}
#endif
webHostBuilder = webHostBuilder.UseKestrel().UseIISIntegration();
}
else
{
throw new InvalidOperationException($"Unknown server value: {Server}");
}

var webHost = webHostBuilder.Build();
var webHost = hostBuilder.Build();

Console.WriteLine($"Using server {Server}");
Console.WriteLine($"Server GC is currently {(GCSettings.IsServerGC ? "ENABLED" : "DISABLED")}");
Expand All @@ -159,7 +163,9 @@ public static void Main(string[] args)
StartInteractiveConsoleThread();
}

webHost.Run();
webHost.Start();
Console.WriteLine("Application started. Press Ctrl+C to shut down.");
webHost.WaitForShutdown();
}

private static void StartInteractiveConsoleThread()
Expand Down
23 changes: 15 additions & 8 deletions src/Benchmarks/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Npgsql;
using System.IO;
using Microsoft.AspNetCore.WebUtilities;
Expand All @@ -27,7 +28,7 @@ namespace Benchmarks
{
public class Startup
{
public Startup(IHostingEnvironment hostingEnv, Scenarios scenarios)
public Startup(IWebHostEnvironment hostingEnv)
{
// Set up configuration sources.
var builder = new ConfigurationBuilder()
Expand All @@ -38,21 +39,27 @@ public Startup(IHostingEnvironment hostingEnv, Scenarios scenarios)
.AddCommandLine(Program.Args);

Configuration = builder.Build();

Scenarios = scenarios;
}

public IConfigurationRoot Configuration { get; set; }

public Scenarios Scenarios { get; }
public Scenarios Scenarios { get; private set; }

public void ConfigureServices(IServiceCollection services)
{
services.Configure<AppSettings>(Configuration);

// We re-register the Scenarios as an instance singleton here to avoid it being created again due to the
// registration done in Program.Main
services.AddSingleton(Scenarios);
// Retrieve Scenarios that was registered in Program.Main
// We need it throughout ConfigureServices, so we must call BuildServiceProvider here.
// Warning suppression justification:
// Duplicate Scenarios will not cause issues as it is a singleton and we re-register the same instance below.
// Moving to a different pattern would require significant refactoring.
#pragma warning disable ASP0000 // Do not call 'BuildServiceProvider' in 'ConfigureServices'
using (var serviceProvider = services.BuildServiceProvider())
{
Scenarios = serviceProvider.GetRequiredService<Scenarios>();
}
#pragma warning restore ASP0000

// Common DB services
services.AddSingleton<IRandom, DefaultRandom>();
Expand Down Expand Up @@ -230,7 +237,7 @@ INSERT INTO fortune (message)
}
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
Expand Down
Loading