33 lines
1022 B
C#
33 lines
1022 B
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace EntityFrameworkCore.Data.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddTeamLeaguesAndCoachesView : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
// I added this SQL manually, by first creating an empty migration.
|
|
// A view is a read-only representation of a data set.
|
|
migrationBuilder.Sql(@"
|
|
CREATE VIEW vw_TeamsAndLeagues
|
|
AS
|
|
SELECT t.name, l.Name AS LeagueName
|
|
FROM Teams AS t
|
|
LEFT JOIN Leagues AS l ON t.LeagueId = l.Id
|
|
");
|
|
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
// Don't forget this part as well, for each manually added SQL statement.
|
|
migrationBuilder.Sql(@"DROP VIEW vw_TeamsAndLeagues");
|
|
}
|
|
}
|
|
}
|