Skip to content
Merged
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
1 change: 0 additions & 1 deletion Aspire.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@
<Project Path="playground/SqlServerEndToEnd/SqlServerEndToEnd.ApiService/SqlServerEndToEnd.ApiService.csproj" />
<Project Path="playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/SqlServerEndToEnd.AppHost.csproj" />
<Project Path="playground/SqlServerEndToEnd/SqlServerEndToEnd.Common/SqlServerEndToEnd.Common.csproj" />
<Project Path="playground/SqlServerEndToEnd/SqlServerEndToEnd.DbSetup/SqlServerEndToEnd.DbSetup.csproj" />
</Folder>
<Folder Name="/playground/SqlServerScript/">
<Project Path="playground/SqlServerScript/AppHost1/AppHost1.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
Expand All @@ -10,6 +10,10 @@
<AspireProjectOrPackageReference Include="Aspire.Microsoft.EntityFrameworkCore.SqlServer" />
<ProjectReference Include="..\..\Playground.ServiceDefaults\Playground.ServiceDefaults.csproj" />
<ProjectReference Include="..\SqlServerEndToEnd.Common\SqlServerEndToEnd.Common.csproj" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
31 changes: 20 additions & 11 deletions playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,28 @@
var sql2 = builder.AddAzureSqlServer("sql2");
var db2 = sql2.AddDatabase("db2");

var dbsetup = builder.AddProject<Projects.SqlServerEndToEnd_DbSetup>("dbsetup")
.WithReference(db1).WaitFor(sql1)
.WithReference(db2).WaitFor(sql2);
var api = builder.AddProject<Projects.SqlServerEndToEnd_ApiService>("api")
.WithExternalHttpEndpoints();

// Add EF migrations resource for the dbsetup project
// Add EF migrations resource for the api project
// This adds dashboard commands for managing EF migrations
var dbMigrations = dbsetup.AddEFMigrations("db-migrations");

builder.AddProject<Projects.SqlServerEndToEnd_ApiService>("api")
.WithExternalHttpEndpoints()
.WithReference(db1).WaitFor(db1)
.WithReference(db2).WaitFor(db2)
.WaitForCompletion(dbsetup);
var db1Migrations = api.AddEFMigrations("db1-migrations", "MyDb1Context")
.WithMigrationsProject<Projects.SqlServerEndToEnd_Common>()
.WithMigrationOutputDirectory("Db1Migrations")
.RunDatabaseUpdateOnStart() // Note that this only works during local development. The migrations resource is not deployed.
.PublishAsMigrationBundle(publishContainer: true)
.WithReference(db1).WaitFor(db1);

var db2Migrations = api.AddEFMigrations("db2-migrations", "MyDb2Context")
.WithMigrationsProject<Projects.SqlServerEndToEnd_Common>()
.WithMigrationOutputDirectory("Db2Migrations")
.RunDatabaseUpdateOnStart() // Note that this only works during local development. The migrations resource is not deployed.
Comment thread
AndriySvyryd marked this conversation as resolved.
.PublishAsMigrationBundle(publishContainer: true)
.WithReference(db2).WaitFor(db2);

api
.WaitForCompletion(db1Migrations)
.WaitForCompletion(db2Migrations);

#if !SKIP_DASHBOARD_REFERENCE
// This project is only added in playground projects to support development/debugging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<AspireProjectOrPackageReference Include="Aspire.Hosting.EntityFrameworkCore" />

<ProjectReference Include="..\SqlServerEndToEnd.ApiService\SqlServerEndToEnd.ApiService.csproj" />
<ProjectReference Include="..\SqlServerEndToEnd.DbSetup\SqlServerEndToEnd.DbSetup.csproj" />
<ProjectReference Include="..\SqlServerEndToEnd.Common\SqlServerEndToEnd.Common.csproj" />
</ItemGroup>

</Project>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace SqlServerEndToEnd.Common.Db1;

/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Entries",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Entries", x => x.Id);
});
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Entries");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SqlServerEndToEnd.Common;

#nullable disable

namespace SqlServerEndToEnd.Common.Db1
{
[DbContext(typeof(MyDb1Context))]
partial class MyDb1ContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.26")
.HasAnnotation("Relational:MaxIdentifierLength", 128);

SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);

modelBuilder.Entity("SqlServerEndToEnd.Common.Entry", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");

b.HasKey("Id");

b.ToTable("Entries");
});
#pragma warning restore 612, 618
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace SqlServerEndToEnd.Common.Db2;

/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Entries",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Entries", x => x.Id);
});
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Entries");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SqlServerEndToEnd.Common;

#nullable disable

namespace SqlServerEndToEnd.Common.Db2
{
[DbContext(typeof(MyDb2Context))]
partial class MyDb2ContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.26")
.HasAnnotation("Relational:MaxIdentifierLength", 128);

SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);

modelBuilder.Entity("SqlServerEndToEnd.Common.Entry", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");

b.HasKey("Id");

b.ToTable("Entries");
});
#pragma warning restore 612, 618
}
}
}
22 changes: 0 additions & 22 deletions playground/SqlServerEndToEnd/SqlServerEndToEnd.DbSetup/Program.cs

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading