using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace EntityFrameworkCore.Data.Migrations { /// public partial class AddTeamLeaguesAndCoachesView : Migration { /// 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 "); } /// 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"); } } }