diff --git a/Aspire.sln b/Aspire.sln index b96f0767876..9b7c97973bc 100644 --- a/Aspire.sln +++ b/Aspire.sln @@ -205,6 +205,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.Pomelo.EntityFramewo EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.Pomelo.EntityFrameworkCore.MySql.Tests", "tests\Aspire.Pomelo.EntityFrameworkCore.MySql.Tests\Aspire.Pomelo.EntityFrameworkCore.MySql.Tests.csproj", "{BFAF55A8-A737-4EC1-BBA2-76001A8F16E0}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SqlServerEndToEnd", "SqlServerEndToEnd", "{2CA6AB88-21EF-4488-BB1B-3A5BAD5FE2AD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlServerEndToEnd.AppHost", "playground\SqlServerEndToEnd\SqlServerEndToEnd.AppHost\SqlServerEndToEnd.AppHost.csproj", "{7616FD70-6BEC-439D-B39E-A838F939C0F9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlServerEndToEnd.ApiService", "playground\SqlServerEndToEnd\SqlServerEndToEnd.ApiService\SqlServerEndToEnd.ApiService.csproj", "{78ABCF96-507B-4E5F-9265-CACC3EFD4C53}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -551,6 +557,14 @@ Global {BFAF55A8-A737-4EC1-BBA2-76001A8F16E0}.Debug|Any CPU.Build.0 = Debug|Any CPU {BFAF55A8-A737-4EC1-BBA2-76001A8F16E0}.Release|Any CPU.ActiveCfg = Release|Any CPU {BFAF55A8-A737-4EC1-BBA2-76001A8F16E0}.Release|Any CPU.Build.0 = Release|Any CPU + {7616FD70-6BEC-439D-B39E-A838F939C0F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7616FD70-6BEC-439D-B39E-A838F939C0F9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7616FD70-6BEC-439D-B39E-A838F939C0F9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7616FD70-6BEC-439D-B39E-A838F939C0F9}.Release|Any CPU.Build.0 = Release|Any CPU + {78ABCF96-507B-4E5F-9265-CACC3EFD4C53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {78ABCF96-507B-4E5F-9265-CACC3EFD4C53}.Debug|Any CPU.Build.0 = Debug|Any CPU + {78ABCF96-507B-4E5F-9265-CACC3EFD4C53}.Release|Any CPU.ActiveCfg = Release|Any CPU + {78ABCF96-507B-4E5F-9265-CACC3EFD4C53}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -647,6 +661,9 @@ Global {25208C6F-0A9D-4D60-9EDD-256C9891B1CD} = {D173887B-AF42-4576-B9C1-96B9E9B3D9C0} {C565532A-0754-44FE-A0C7-78D5338DDBCA} = {27381127-6C45-4B4C-8F18-41FF48DFE4B2} {BFAF55A8-A737-4EC1-BBA2-76001A8F16E0} = {4981B3A5-4AFD-4191-BF7D-8692D9783D60} + {2CA6AB88-21EF-4488-BB1B-3A5BAD5FE2AD} = {D173887B-AF42-4576-B9C1-96B9E9B3D9C0} + {7616FD70-6BEC-439D-B39E-A838F939C0F9} = {2CA6AB88-21EF-4488-BB1B-3A5BAD5FE2AD} + {78ABCF96-507B-4E5F-9265-CACC3EFD4C53} = {2CA6AB88-21EF-4488-BB1B-3A5BAD5FE2AD} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6DCEDFEC-988E-4CB3-B45B-191EB5086E0C} diff --git a/playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/Program.cs b/playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/Program.cs new file mode 100644 index 00000000000..3d4e45a0d02 --- /dev/null +++ b/playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/Program.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.EntityFrameworkCore; + +var builder = WebApplication.CreateBuilder(args); + +builder.AddServiceDefaults(); + +builder.AddSqlServerDbContext("db"); + +var app = builder.Build(); + +app.MapGet("/", async (MyDbContext context) => +{ + // You wouldn't normally do this on every call, + // but doing it here just to make this simple. + context.Database.EnsureCreated(); + + var entry = new Entry(); + await context.Entries.AddAsync(entry); + await context.SaveChangesAsync(); + + var entries = await context.Entries.ToListAsync(); + + return new + { + totalEntries = entries.Count, + entries = entries + }; +}); + +app.Run(); + +public class MyDbContext(DbContextOptions options) : DbContext(options) +{ + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.Entity().HasKey(e => e.Id); + } + + public DbSet Entries { get; set; } +} + +public class Entry +{ + public Guid Id { get; set; } = Guid.NewGuid(); +} diff --git a/playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/Properties/launchSettings.json b/playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/Properties/launchSettings.json new file mode 100644 index 00000000000..f7bf310e7ae --- /dev/null +++ b/playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/Properties/launchSettings.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5180", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/SqlServerEndToEnd.ApiService.csproj b/playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/SqlServerEndToEnd.ApiService.csproj new file mode 100644 index 00000000000..6caccbe4360 --- /dev/null +++ b/playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/SqlServerEndToEnd.ApiService.csproj @@ -0,0 +1,14 @@ + + + + net8.0 + enable + enable + + + + + + + + diff --git a/playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/SqlServerEndToEnd.ApiService.http b/playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/SqlServerEndToEnd.ApiService.http new file mode 100644 index 00000000000..59fcd09ca55 --- /dev/null +++ b/playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/SqlServerEndToEnd.ApiService.http @@ -0,0 +1,6 @@ +@CosmosEndToEnd.ApiService_HostAddress = http://localhost:5193 + +GET {{SqlServerEndToEnd.ApiService_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/appsettings.Development.json b/playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/appsettings.Development.json new file mode 100644 index 00000000000..0c208ae9181 --- /dev/null +++ b/playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/appsettings.json b/playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/appsettings.json new file mode 100644 index 00000000000..10f68b8c8b4 --- /dev/null +++ b/playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/Directory.Build.props b/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/Directory.Build.props new file mode 100644 index 00000000000..b9b39c05e81 --- /dev/null +++ b/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/Directory.Build.props @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/Directory.Build.targets b/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/Directory.Build.targets new file mode 100644 index 00000000000..b7ba77268f8 --- /dev/null +++ b/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/Directory.Build.targets @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/Program.cs b/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/Program.cs new file mode 100644 index 00000000000..e2dbe5f854c --- /dev/null +++ b/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/Program.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +var builder = DistributedApplication.CreateBuilder(args); + +var db = builder.AddSqlServer("sql").AddDatabase("db"); + +builder.AddProject("api") + .WithReference(db); + +// This project is only added in playground projects to support development/debugging +// of the dashboard. It is not required in end developer code. Comment out this code +// to test end developer dashboard launch experience. Refer to Directory.Build.props +// for the path to the dashboard binary (defaults to the Aspire.Dashboard bin output +// in the artifacts dir). +//builder.AddProject(KnownResourceNames.AspireDashboard); + +builder.Build().Run(); diff --git a/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/Properties/launchSettings.json b/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/Properties/launchSettings.json new file mode 100644 index 00000000000..16aca777b1e --- /dev/null +++ b/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:15888", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16175", + "DOTNET_ASPIRE_SHOW_DASHBOARD_RESOURCES": "true" // Display dashboard resource in console for local development + } + }, + "generate-manifest": { + "commandName": "Project", + "launchBrowser": true, + "dotnetRunMessages": true, + "commandLineArgs": "--publisher manifest --output-path aspire-manifest.json", + "applicationUrl": "http://localhost:15888", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16175" + } + } + } +} diff --git a/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/SqlServerEndToEnd.AppHost.csproj b/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/SqlServerEndToEnd.AppHost.csproj new file mode 100644 index 00000000000..ff809fd13bf --- /dev/null +++ b/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/SqlServerEndToEnd.AppHost.csproj @@ -0,0 +1,22 @@ + + + + Exe + net8.0 + enable + enable + true + + + + + + + + + + + + + + diff --git a/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/appsettings.Development.json b/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/appsettings.Development.json new file mode 100644 index 00000000000..0c208ae9181 --- /dev/null +++ b/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/appsettings.json b/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/appsettings.json new file mode 100644 index 00000000000..31c092aa450 --- /dev/null +++ b/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Aspire.Hosting.Dcp": "Warning" + } + } +}