Compare commits

..

No commits in common. "024f9da8f9db507b6697d6bada7c803a257fee1d" and "56fd0e44e7485d25ef82265f641c4540965fcd02" have entirely different histories.

21 changed files with 77 additions and 2610 deletions

View File

@ -1,126 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using EntityFrameworkCore.Data;
using EntityFrameworkCore.Domain;
namespace EntityFrameworkCore.API.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class TeamsController : ControllerBase
{
private readonly DeadBallZoneLeagueDbContext _context;
public TeamsController(DeadBallZoneLeagueDbContext context)
{
_context = context;
}
// GET: api/Teams
[HttpGet]
public async Task<ActionResult<IEnumerable<TeamDto>>> GetTeams()
{
if (_context.Teams == null)
{
return NotFound();
}
var teams = await _context.Teams
.Select(t => new TeamDto
{
Id = t.Id,
Name = t.Name,
CoachName = t.Coach.Name
})
.ToListAsync();
return teams;
}
// GET: api/Teams/5
[HttpGet("{id}")]
public async Task<ActionResult<Team>> GetTeam(int id)
{
if (_context.Teams == null)
{
return NotFound();
}
// using λ for fun here.
var team = await _context.Teams
.Include(λ => λ.Coach)
.Include(λ => λ.League)
.FirstOrDefaultAsync(λ => λ.Id == id);
if (team == null)
{
return NotFound();
}
return team;
}
// PUT: api/Teams/5
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
[HttpPut("{id}")]
public async Task<IActionResult> PutTeam(int id, Team team)
{
if (id != team.Id)
{
return BadRequest();
}
_context.Entry(team).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!TeamExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return NoContent();
}
// POST: api/Teams
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
[HttpPost]
public async Task<ActionResult<Team>> PostTeam(Team team)
{
_context.Teams.Add(team);
await _context.SaveChangesAsync();
return CreatedAtAction("GetTeam", new { id = team.Id }, team);
}
// DELETE: api/Teams/5
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteTeam(int id)
{
if (_context.Teams == null)
{
return NotFound();
}
await _context.Teams.Where(t => t.Id == id).ExecuteDeleteAsync();
return NoContent();
}
private bool TeamExists(int id)
{
return _context.Teams.Any(e => e.Id == id);
}
}
}

View File

@ -8,19 +8,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="9.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../EntityFrameworkCore.Data/EntityFrameworkCore.Data.csproj" />
</ItemGroup>
</Project>

View File

@ -1,8 +0,0 @@
namespace EntityFrameworkCore.API;
public class TeamDto
{
public int Id { get; set; }
public string Name { get; set; }
public string CoachName { get; set; }
}

View File

@ -1,42 +1,9 @@
using EntityFrameworkCore.Data;
using Microsoft.EntityFrameworkCore;
using System.Text.Json.Serialization;
using EntityFrameworkCore.API.Controllers;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers().AddJsonOptions(options =>
{
// IgnoreCycles prevents "System.Text.Json.JsonException: A possible object cycle was detected".
options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles;
});
// Add services to the container.
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();
var sqliteDatabaseName = builder.Configuration.GetConnectionString("SqliteDatabaseName");
var folder = Environment.SpecialFolder.LocalApplicationData;
var path = Environment.GetFolderPath(folder);
var dbPath = Path.Combine(path, sqliteDatabaseName);
var connectionString = $"Data Source={dbPath}";
builder.Services.AddDbContext<DeadBallZoneLeagueDbContext>(options => {
options.UseSqlite(connectionString, sqliteOptions => {
sqliteOptions.CommandTimeout(30); // 30 second timeout.
})
.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking)
.LogTo(Console.WriteLine, LogLevel.Information);
if (!builder.Environment.IsProduction())
{
// Do not allow this in Production.
options.EnableSensitiveDataLogging();
options.EnableDetailedErrors();
}
});
var app = builder.Build();
// Configure the HTTP request pipeline.
@ -47,6 +14,28 @@ if (app.Environment.IsDevelopment())
app.UseHttpsRedirection();
app.MapControllers();
var summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
app.MapGet("/weatherforecast", () =>
{
var forecast = Enumerable.Range(1, 5).Select(index =>
new WeatherForecast
(
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
Random.Shared.Next(-20, 55),
summaries[Random.Shared.Next(summaries.Length)]
))
.ToArray();
return forecast;
})
.WithName("GetWeatherForecast");
app.Run();
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
{
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}

View File

@ -5,8 +5,5 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"SqliteDatabaseName": "DeadBallZoneLeague_EFCore.db"
}
"AllowedHosts": "*"
}

View File

@ -3,13 +3,7 @@ using EntityFrameworkCore.Domain;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
var folder = Environment.SpecialFolder.LocalApplicationData;
var path = Environment.GetFolderPath(folder);
var dbPath = Path.Combine(path, "DeadBallZoneLeague_EFCore.db");
var optionsBuilder = new DbContextOptionsBuilder<DeadBallZoneLeagueDbContext>();
optionsBuilder.UseSqlite($"Data Source={dbPath}");
using var context = new DeadBallZoneLeagueDbContext(optionsBuilder.Options);
using var context = new DeadBallZoneLeagueDbContext();
// context.Database.Migrate(); // Can be used to automatically migrate on run.
context.Database.EnsureCreated();
@ -22,90 +16,6 @@ context.Database.EnsureCreated();
// Rather than raise: "System.InvalidOperationException: Sequence contains no elements."
// var firstCoach = await context.Coaches.FirstOrDefaultAsync();
async Task SoftDeleteLeague()
{
var league = context.Leagues.Find(1);
league.IsDeleted = true;
context.SaveChanges();
// This is rather cumbersome. Instead, use a query filter. See League configuration.
//var leagues = context.Leagues.Where(l => !l.IsDeleted).ToList();
// This now gets all leagues, with query filters applied.
var leagues = context.Leagues.ToList();
// You can also ignore them, if you want in a specific case.
leagues = context.Leagues.IgnoreQueryFilters().ToList();
}
async Task ConcurrencyCheckExample()
{
var team = context.Teams.Find(1);
team.Name = "New name";
// To simulate a concurrency change, add a breakpoint and
// manually update the GUID in the database before SaveChangesAsync is called.
// See also: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=data-annotations
try
{
await context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException ex)
{
Console.WriteLine(ex.Message);
}
}
async Task TransactionWithSavepoint()
{
var transaction = context.Database.BeginTransaction();
var league = new League
{
Name = "Geosphere league"
};
context.Add(league);
context.SaveChanges();
transaction.CreateSavepoint("CreatedLeague");
var coach = new Coach
{
Name = "Brad Ironfist"
};
context.Add(coach);
context.SaveChanges();
var teams = new List<Team>
{
new Team
{
Name = "Dominators",
LeagueId = league.Id,
CoachId = coach.Id
}
};
context.AddRange(teams);
context.SaveChanges();
try
{
transaction.Commit();
}
catch (Exception)
{
// Rollback everything.
//transaction.Rollback();
// Or rollback to a specific save point.
transaction.RollbackToSavepoint("CreatedLeague");
throw;
}
}
async Task UserDefinedQuery()
{

View File

@ -8,10 +8,6 @@ public class LeagueConfiguration : IEntityTypeConfiguration<League>
{
public void Configure(EntityTypeBuilder<League> builder)
{
// This query filter will be always applied.
// Note that you should call HasQueryFilter only once, otherwise the filter is overwritten.
builder.HasQueryFilter(l => l.IsDeleted == false);
builder.HasData(
new League { Id = 1, Name = "Local League", CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33)},
new League { Id = 2, Name = "National League", CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33)},

View File

@ -10,17 +10,6 @@ public class TeamConfiguration : IEntityTypeConfiguration<Team>
{
builder.HasIndex(t => t.Name).IsUnique();
// example composite key configuration.
// builder.HasIndex(λ => new { λ.CoachId, λ.LeagueId }).IsUnique();
// SQL Server method to setup concurrency.
// builder.Property(λ => λ.Version).IsRowVersion();
// SQLite (and other) method to setup concurrency. See also BaseDomain model.
builder.Property(λ => λ.Version).IsConcurrencyToken();
builder.Property(λ => λ.Name).HasMaxLength(100).IsRequired();
builder.HasMany(m => m.HomeMatches) // A team has many home matches.
.WithOne(m => m.HomeTeam) // Mapped to the HomeTeam property.
.HasForeignKey(m => m.HomeTeamId)

View File

@ -1,26 +1,36 @@
using Microsoft.EntityFrameworkCore;
using EntityFrameworkCore.Domain;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System.Reflection;
using Microsoft.EntityFrameworkCore.Design;
namespace EntityFrameworkCore.Data;
public class DeadBallZoneLeagueDbContext : DbContext
{
public DeadBallZoneLeagueDbContext(DbContextOptions<DeadBallZoneLeagueDbContext> options) : base(options)
private string DbPath;
public DeadBallZoneLeagueDbContext()
{
// This constuctor allows it to accept the options set from other instances, such as in the API project.
// In Ubuntu 24.04, the file is created here: /home/user/.local/share
var folder = Environment.SpecialFolder.LocalApplicationData;
var path = Environment.GetFolderPath(folder);
DbPath = Path.Combine(path, "DeadBallZoneLeague_EFCore.db");
}
public DbSet<Team> Teams { get; set; }
public DbSet<Coach> Coaches { get; set; }
public DbSet<League> Leagues { get; set; }
public DbSet<Match> Matches { get; set; }
public DbSet<TeamsAndLeaguesView> TeamsAndLeaguesView { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite($"Data source={DbPath}")
// .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking) // Do not use tracking, set globally on all queries.
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging() // Do not allow this in Production.
.EnableDetailedErrors(); // Do not allow this in Production.
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// modelBuilder.ApplyConfiguration(new TeamConfiguration());
@ -42,63 +52,5 @@ public class DeadBallZoneLeagueDbContext : DbContext
.HasName("GetEarliestMatch");
}
// This is an example override for SQL Server:
// protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseSqlServer("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=FootballLeague_EfCore; Encrypt=true", sqlOptions => {
// sqlOptions.EnableRetryOnFailure(maxRetryCount: 5,
// maxRetryDelay: TimeSpan.FromSeconds(5),
// errorNumbersToAdd: null);
// });
protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
{
// These apply to all the settings for all models.
configurationBuilder.Properties<string>().HaveMaxLength(100);
configurationBuilder.Properties<decimal>().HavePrecision(16, 2);
}
public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
{
var entries = ChangeTracker.Entries<BaseDomainModel>().Where(
λ => λ.State == EntityState.Modified || λ.State == EntityState.Added
);
// Whenever a save is made to an entity, these fields are now automatically updated:
foreach (var entry in entries)
{
entry.Entity.ModifiedDate = DateTime.UtcNow;
entry.Entity.ModifiedBy = "Sample User 1";
if (entry.State == EntityState.Added)
{
entry.Entity.CreatedDate = DateTime.UtcNow;
entry.Entity.CreatedBy = "Sample User";
}
// Update the concurrency token.
entry.Entity.Version = Guid.NewGuid();
}
return base.SaveChangesAsync(cancellationToken);
}
public DateTime GetEarliestTeamMatch(int teamId) => throw new NotImplementedException();
}
public class DeadBallZoneLeagueDbContextFactory : IDesignTimeDbContextFactory<DeadBallZoneLeagueDbContext>
{
public DeadBallZoneLeagueDbContext CreateDbContext(string[] args)
{
var folder = Environment.SpecialFolder.LocalApplicationData;
var path = Environment.GetFolderPath(folder);
IConfigurationRoot configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build();
var dbPath = Path.Combine(path, configuration.GetConnectionString("SqliteDatabaseName"));
var optionsBuilder = new DbContextOptionsBuilder<DeadBallZoneLeagueDbContext>();
optionsBuilder.UseSqlite($"Data Source={dbPath}");
return new DeadBallZoneLeagueDbContext(optionsBuilder.Options);
}
}

View File

@ -9,9 +9,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.3" />
</ItemGroup>
<ItemGroup>

View File

@ -1,506 +0,0 @@
// <auto-generated />
using System;
using EntityFrameworkCore.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFrameworkCore.Data.Migrations
{
[DbContext(typeof(DeadBallZoneLeagueDbContext))]
[Migration("20250414192903_AddRestriction")]
partial class AddRestriction
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.3");
modelBuilder.Entity("EntityFrameworkCore.Domain.Coach", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<string>("ModifiedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Coaches");
b.HasData(
new
{
Id = 1,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Christian Southgate"
},
new
{
Id = 2,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Rob Mann"
},
new
{
Id = 3,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Jon Curtis"
},
new
{
Id = 4,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Andy Taylor"
},
new
{
Id = 5,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Steve Johnson"
},
new
{
Id = 6,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Dan Cook"
},
new
{
Id = 7,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Ken Jarvis"
},
new
{
Id = 8,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Kenny Suzuki"
},
new
{
Id = 9,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Gordon Hall"
},
new
{
Id = 10,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "John O Dowd"
},
new
{
Id = 11,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Julian Widdows"
},
new
{
Id = 12,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Andy Williams"
},
new
{
Id = 13,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Trevor Williams"
},
new
{
Id = 14,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Blake Deathray"
},
new
{
Id = 15,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Rock Housebrick"
});
});
modelBuilder.Entity("EntityFrameworkCore.Domain.League", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<string>("ModifiedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Leagues");
b.HasData(
new
{
Id = 1,
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Local League"
},
new
{
Id = 2,
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "National League"
},
new
{
Id = 3,
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Geosphere"
},
new
{
Id = 4,
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Cyber war"
});
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Match", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("AwayTeamId")
.HasColumnType("INTEGER");
b.Property<int>("AwayTeamScore")
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<int>("HomeTeamId")
.HasColumnType("INTEGER");
b.Property<int>("HomeTeamScore")
.HasColumnType("INTEGER");
b.Property<string>("ModifiedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<decimal>("TicketPrice")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("AwayTeamId");
b.HasIndex("HomeTeamId");
b.ToTable("Matches");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("CoachId")
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<int?>("LeagueId")
.HasColumnType("INTEGER");
b.Property<string>("ModifiedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("CoachId")
.IsUnique();
b.HasIndex("LeagueId");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Teams");
b.HasData(
new
{
Id = 1,
CoachId = 1,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 2,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Delhi"
},
new
{
Id = 2,
CoachId = 2,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Voodoo"
},
new
{
Id = 3,
CoachId = 3,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Penal X"
},
new
{
Id = 4,
CoachId = 4,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 3,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Tokyo"
},
new
{
Id = 5,
CoachId = 5,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 2,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Barcelona"
},
new
{
Id = 6,
CoachId = 6,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 2,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Manchester"
},
new
{
Id = 7,
CoachId = 7,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 3,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Bangkok"
},
new
{
Id = 8,
CoachId = 8,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 3,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Amsterdam"
},
new
{
Id = 9,
CoachId = 9,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Killaklowns"
},
new
{
Id = 10,
CoachId = 10,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Sol"
},
new
{
Id = 11,
CoachId = 11,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 4,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "DEC"
},
new
{
Id = 12,
CoachId = 12,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Leopards"
},
new
{
Id = 13,
CoachId = 13,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Harlequins"
},
new
{
Id = 14,
CoachId = 14,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 4,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Gladiators"
},
new
{
Id = 15,
CoachId = 15,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Fiz-O"
});
});
modelBuilder.Entity("EntityFrameworkCore.Domain.TeamsAndLeaguesView", b =>
{
b.Property<string>("LeagueName")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.ToTable((string)null);
b.ToView("vw_TeamsAndLeagues", (string)null);
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Match", b =>
{
b.HasOne("EntityFrameworkCore.Domain.Team", "AwayTeam")
.WithMany("AwayMatches")
.HasForeignKey("AwayTeamId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("EntityFrameworkCore.Domain.Team", "HomeTeam")
.WithMany("HomeMatches")
.HasForeignKey("HomeTeamId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("AwayTeam");
b.Navigation("HomeTeam");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
{
b.HasOne("EntityFrameworkCore.Domain.Coach", "Coach")
.WithOne("Team")
.HasForeignKey("EntityFrameworkCore.Domain.Team", "CoachId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkCore.Domain.League", "League")
.WithMany("Teams")
.HasForeignKey("LeagueId");
b.Navigation("Coach");
b.Navigation("League");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Coach", b =>
{
b.Navigation("Team");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.League", b =>
{
b.Navigation("Teams");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
{
b.Navigation("AwayMatches");
b.Navigation("HomeMatches");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,38 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFrameworkCore.Data.Migrations
{
/// <inheritdoc />
public partial class AddRestriction : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "Teams",
type: "TEXT",
maxLength: 100,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "Teams",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT",
oldMaxLength: 100);
}
}
}

View File

@ -1,568 +0,0 @@
// <auto-generated />
using System;
using EntityFrameworkCore.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFrameworkCore.Data.Migrations
{
[DbContext(typeof(DeadBallZoneLeagueDbContext))]
[Migration("20250414200332_AddConcurrencyCheckVersionToken")]
partial class AddConcurrencyCheckVersionToken
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.3");
modelBuilder.Entity("EntityFrameworkCore.Domain.Coach", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<string>("ModifiedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<Guid>("Version")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Coaches");
b.HasData(
new
{
Id = 1,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Christian Southgate",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 2,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Rob Mann",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 3,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Jon Curtis",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 4,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Andy Taylor",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 5,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Steve Johnson",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 6,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Dan Cook",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 7,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Ken Jarvis",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 8,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Kenny Suzuki",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 9,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Gordon Hall",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 10,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "John O Dowd",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 11,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Julian Widdows",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 12,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Andy Williams",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 13,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Trevor Williams",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 14,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Blake Deathray",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 15,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Rock Housebrick",
Version = new Guid("00000000-0000-0000-0000-000000000000")
});
});
modelBuilder.Entity("EntityFrameworkCore.Domain.League", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<string>("ModifiedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<Guid>("Version")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Leagues");
b.HasData(
new
{
Id = 1,
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Local League",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 2,
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "National League",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 3,
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Geosphere",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 4,
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Cyber war",
Version = new Guid("00000000-0000-0000-0000-000000000000")
});
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Match", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("AwayTeamId")
.HasColumnType("INTEGER");
b.Property<int>("AwayTeamScore")
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<int>("HomeTeamId")
.HasColumnType("INTEGER");
b.Property<int>("HomeTeamScore")
.HasColumnType("INTEGER");
b.Property<string>("ModifiedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<decimal>("TicketPrice")
.HasPrecision(16, 2)
.HasColumnType("TEXT");
b.Property<Guid>("Version")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("AwayTeamId");
b.HasIndex("HomeTeamId");
b.ToTable("Matches");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("CoachId")
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<int?>("LeagueId")
.HasColumnType("INTEGER");
b.Property<string>("ModifiedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<Guid>("Version")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("CoachId")
.IsUnique();
b.HasIndex("LeagueId");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Teams");
b.HasData(
new
{
Id = 1,
CoachId = 1,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 2,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Delhi",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 2,
CoachId = 2,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Voodoo",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 3,
CoachId = 3,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Penal X",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 4,
CoachId = 4,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 3,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Tokyo",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 5,
CoachId = 5,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 2,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Barcelona",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 6,
CoachId = 6,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 2,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Manchester",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 7,
CoachId = 7,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 3,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Bangkok",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 8,
CoachId = 8,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 3,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Amsterdam",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 9,
CoachId = 9,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Killaklowns",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 10,
CoachId = 10,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Sol",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 11,
CoachId = 11,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 4,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "DEC",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 12,
CoachId = 12,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Leopards",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 13,
CoachId = 13,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Harlequins",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 14,
CoachId = 14,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 4,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Gladiators",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 15,
CoachId = 15,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Fiz-O",
Version = new Guid("00000000-0000-0000-0000-000000000000")
});
});
modelBuilder.Entity("EntityFrameworkCore.Domain.TeamsAndLeaguesView", b =>
{
b.Property<string>("LeagueName")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.ToTable((string)null);
b.ToView("vw_TeamsAndLeagues", (string)null);
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Match", b =>
{
b.HasOne("EntityFrameworkCore.Domain.Team", "AwayTeam")
.WithMany("AwayMatches")
.HasForeignKey("AwayTeamId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("EntityFrameworkCore.Domain.Team", "HomeTeam")
.WithMany("HomeMatches")
.HasForeignKey("HomeTeamId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("AwayTeam");
b.Navigation("HomeTeam");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
{
b.HasOne("EntityFrameworkCore.Domain.Coach", "Coach")
.WithOne("Team")
.HasForeignKey("EntityFrameworkCore.Domain.Team", "CoachId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkCore.Domain.League", "League")
.WithMany("Teams")
.HasForeignKey("LeagueId");
b.Navigation("Coach");
b.Navigation("League");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Coach", b =>
{
b.Navigation("Team");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.League", b =>
{
b.Navigation("Teams");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
{
b.Navigation("AwayMatches");
b.Navigation("HomeMatches");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,301 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFrameworkCore.Data.Migrations
{
/// <inheritdoc />
public partial class AddConcurrencyCheckVersionToken : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "Version",
table: "Teams",
type: "TEXT",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<Guid>(
name: "Version",
table: "Matches",
type: "TEXT",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<Guid>(
name: "Version",
table: "Leagues",
type: "TEXT",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<Guid>(
name: "Version",
table: "Coaches",
type: "TEXT",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Coaches",
keyColumn: "Id",
keyValue: 1,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Coaches",
keyColumn: "Id",
keyValue: 2,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Coaches",
keyColumn: "Id",
keyValue: 3,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Coaches",
keyColumn: "Id",
keyValue: 4,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Coaches",
keyColumn: "Id",
keyValue: 5,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Coaches",
keyColumn: "Id",
keyValue: 6,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Coaches",
keyColumn: "Id",
keyValue: 7,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Coaches",
keyColumn: "Id",
keyValue: 8,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Coaches",
keyColumn: "Id",
keyValue: 9,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Coaches",
keyColumn: "Id",
keyValue: 10,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Coaches",
keyColumn: "Id",
keyValue: 11,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Coaches",
keyColumn: "Id",
keyValue: 12,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Coaches",
keyColumn: "Id",
keyValue: 13,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Coaches",
keyColumn: "Id",
keyValue: 14,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Coaches",
keyColumn: "Id",
keyValue: 15,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Leagues",
keyColumn: "Id",
keyValue: 1,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Leagues",
keyColumn: "Id",
keyValue: 2,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Leagues",
keyColumn: "Id",
keyValue: 3,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Leagues",
keyColumn: "Id",
keyValue: 4,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 1,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 2,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 3,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 4,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 5,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 6,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 7,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 8,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 9,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 10,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 11,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 12,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 13,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 14,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 15,
column: "Version",
value: new Guid("00000000-0000-0000-0000-000000000000"));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Version",
table: "Teams");
migrationBuilder.DropColumn(
name: "Version",
table: "Matches");
migrationBuilder.DropColumn(
name: "Version",
table: "Leagues");
migrationBuilder.DropColumn(
name: "Version",
table: "Coaches");
}
}
}

View File

@ -1,575 +0,0 @@
// <auto-generated />
using System;
using EntityFrameworkCore.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFrameworkCore.Data.Migrations
{
[DbContext(typeof(DeadBallZoneLeagueDbContext))]
[Migration("20250414201323_AddSoftDeleteFlagLeague")]
partial class AddSoftDeleteFlagLeague
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.3");
modelBuilder.Entity("EntityFrameworkCore.Domain.Coach", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<string>("ModifiedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<Guid>("Version")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Coaches");
b.HasData(
new
{
Id = 1,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Christian Southgate",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 2,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Rob Mann",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 3,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Jon Curtis",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 4,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Andy Taylor",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 5,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Steve Johnson",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 6,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Dan Cook",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 7,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Ken Jarvis",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 8,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Kenny Suzuki",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 9,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Gordon Hall",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 10,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "John O Dowd",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 11,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Julian Widdows",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 12,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Andy Williams",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 13,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Trevor Williams",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 14,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Blake Deathray",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 15,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Rock Housebrick",
Version = new Guid("00000000-0000-0000-0000-000000000000")
});
});
modelBuilder.Entity("EntityFrameworkCore.Domain.League", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<bool>("IsDeleted")
.HasColumnType("INTEGER");
b.Property<string>("ModifiedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<Guid>("Version")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Leagues");
b.HasData(
new
{
Id = 1,
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
IsDeleted = false,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Local League",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 2,
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
IsDeleted = false,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "National League",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 3,
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
IsDeleted = false,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Geosphere",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 4,
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
IsDeleted = false,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Cyber war",
Version = new Guid("00000000-0000-0000-0000-000000000000")
});
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Match", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("AwayTeamId")
.HasColumnType("INTEGER");
b.Property<int>("AwayTeamScore")
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<int>("HomeTeamId")
.HasColumnType("INTEGER");
b.Property<int>("HomeTeamScore")
.HasColumnType("INTEGER");
b.Property<string>("ModifiedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<decimal>("TicketPrice")
.HasPrecision(16, 2)
.HasColumnType("TEXT");
b.Property<Guid>("Version")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("AwayTeamId");
b.HasIndex("HomeTeamId");
b.ToTable("Matches");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("CoachId")
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<int?>("LeagueId")
.HasColumnType("INTEGER");
b.Property<string>("ModifiedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<Guid>("Version")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("CoachId")
.IsUnique();
b.HasIndex("LeagueId");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Teams");
b.HasData(
new
{
Id = 1,
CoachId = 1,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 2,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Delhi",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 2,
CoachId = 2,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Voodoo",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 3,
CoachId = 3,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Penal X",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 4,
CoachId = 4,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 3,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Tokyo",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 5,
CoachId = 5,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 2,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Barcelona",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 6,
CoachId = 6,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 2,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Manchester",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 7,
CoachId = 7,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 3,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Bangkok",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 8,
CoachId = 8,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 3,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Amsterdam",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 9,
CoachId = 9,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Killaklowns",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 10,
CoachId = 10,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Sol",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 11,
CoachId = 11,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 4,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "DEC",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 12,
CoachId = 12,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Leopards",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 13,
CoachId = 13,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Harlequins",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 14,
CoachId = 14,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 4,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Gladiators",
Version = new Guid("00000000-0000-0000-0000-000000000000")
},
new
{
Id = 15,
CoachId = 15,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Fiz-O",
Version = new Guid("00000000-0000-0000-0000-000000000000")
});
});
modelBuilder.Entity("EntityFrameworkCore.Domain.TeamsAndLeaguesView", b =>
{
b.Property<string>("LeagueName")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.ToTable((string)null);
b.ToView("vw_TeamsAndLeagues", (string)null);
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Match", b =>
{
b.HasOne("EntityFrameworkCore.Domain.Team", "AwayTeam")
.WithMany("AwayMatches")
.HasForeignKey("AwayTeamId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("EntityFrameworkCore.Domain.Team", "HomeTeam")
.WithMany("HomeMatches")
.HasForeignKey("HomeTeamId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("AwayTeam");
b.Navigation("HomeTeam");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
{
b.HasOne("EntityFrameworkCore.Domain.Coach", "Coach")
.WithOne("Team")
.HasForeignKey("EntityFrameworkCore.Domain.Team", "CoachId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkCore.Domain.League", "League")
.WithMany("Teams")
.HasForeignKey("LeagueId");
b.Navigation("Coach");
b.Navigation("League");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Coach", b =>
{
b.Navigation("Team");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.League", b =>
{
b.Navigation("Teams");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
{
b.Navigation("AwayMatches");
b.Navigation("HomeMatches");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,57 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFrameworkCore.Data.Migrations
{
/// <inheritdoc />
public partial class AddSoftDeleteFlagLeague : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsDeleted",
table: "Leagues",
type: "INTEGER",
nullable: false,
defaultValue: false);
migrationBuilder.UpdateData(
table: "Leagues",
keyColumn: "Id",
keyValue: 1,
column: "IsDeleted",
value: false);
migrationBuilder.UpdateData(
table: "Leagues",
keyColumn: "Id",
keyValue: 2,
column: "IsDeleted",
value: false);
migrationBuilder.UpdateData(
table: "Leagues",
keyColumn: "Id",
keyValue: 3,
column: "IsDeleted",
value: false);
migrationBuilder.UpdateData(
table: "Leagues",
keyColumn: "Id",
keyValue: 4,
column: "IsDeleted",
value: false);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsDeleted",
table: "Leagues");
}
}
}

View File

@ -24,14 +24,12 @@ namespace EntityFrameworkCore.Data.Migrations
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<string>("ModifiedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
@ -39,11 +37,6 @@ namespace EntityFrameworkCore.Data.Migrations
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<Guid>("Version")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.HasKey("Id");
@ -56,120 +49,105 @@ namespace EntityFrameworkCore.Data.Migrations
Id = 1,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Christian Southgate",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Christian Southgate"
},
new
{
Id = 2,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Rob Mann",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Rob Mann"
},
new
{
Id = 3,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Jon Curtis",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Jon Curtis"
},
new
{
Id = 4,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Andy Taylor",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Andy Taylor"
},
new
{
Id = 5,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Steve Johnson",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Steve Johnson"
},
new
{
Id = 6,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Dan Cook",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Dan Cook"
},
new
{
Id = 7,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Ken Jarvis",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Ken Jarvis"
},
new
{
Id = 8,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Kenny Suzuki",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Kenny Suzuki"
},
new
{
Id = 9,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Gordon Hall",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Gordon Hall"
},
new
{
Id = 10,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "John O Dowd",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "John O Dowd"
},
new
{
Id = 11,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Julian Widdows",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Julian Widdows"
},
new
{
Id = 12,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Andy Williams",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Andy Williams"
},
new
{
Id = 13,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Trevor Williams",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Trevor Williams"
},
new
{
Id = 14,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Blake Deathray",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Blake Deathray"
},
new
{
Id = 15,
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Rock Housebrick",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Rock Housebrick"
});
});
@ -180,28 +158,18 @@ namespace EntityFrameworkCore.Data.Migrations
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<bool>("IsDeleted")
.HasColumnType("INTEGER");
b.Property<string>("ModifiedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<Guid>("Version")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.HasKey("Id");
@ -213,37 +181,29 @@ namespace EntityFrameworkCore.Data.Migrations
{
Id = 1,
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
IsDeleted = false,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Local League",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Local League"
},
new
{
Id = 2,
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
IsDeleted = false,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "National League",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "National League"
},
new
{
Id = 3,
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
IsDeleted = false,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Geosphere",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Geosphere"
},
new
{
Id = 4,
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
IsDeleted = false,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Cyber war",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Cyber war"
});
});
@ -260,7 +220,6 @@ namespace EntityFrameworkCore.Data.Migrations
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
@ -276,18 +235,12 @@ namespace EntityFrameworkCore.Data.Migrations
.HasColumnType("INTEGER");
b.Property<string>("ModifiedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<decimal>("TicketPrice")
.HasPrecision(16, 2)
.HasColumnType("TEXT");
b.Property<Guid>("Version")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.HasKey("Id");
@ -309,7 +262,6 @@ namespace EntityFrameworkCore.Data.Migrations
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
@ -319,19 +271,12 @@ namespace EntityFrameworkCore.Data.Migrations
.HasColumnType("INTEGER");
b.Property<string>("ModifiedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<Guid>("Version")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.HasKey("Id");
@ -354,8 +299,7 @@ namespace EntityFrameworkCore.Data.Migrations
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 2,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Delhi",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Neo Delhi"
},
new
{
@ -364,8 +308,7 @@ namespace EntityFrameworkCore.Data.Migrations
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Voodoo",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Voodoo"
},
new
{
@ -374,8 +317,7 @@ namespace EntityFrameworkCore.Data.Migrations
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Penal X",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Penal X"
},
new
{
@ -384,8 +326,7 @@ namespace EntityFrameworkCore.Data.Migrations
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 3,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Tokyo",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Neo Tokyo"
},
new
{
@ -394,8 +335,7 @@ namespace EntityFrameworkCore.Data.Migrations
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 2,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Barcelona",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Neo Barcelona"
},
new
{
@ -404,8 +344,7 @@ namespace EntityFrameworkCore.Data.Migrations
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 2,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Manchester",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Neo Manchester"
},
new
{
@ -414,8 +353,7 @@ namespace EntityFrameworkCore.Data.Migrations
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 3,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Bangkok",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Neo Bangkok"
},
new
{
@ -424,8 +362,7 @@ namespace EntityFrameworkCore.Data.Migrations
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 3,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Amsterdam",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Neo Amsterdam"
},
new
{
@ -434,8 +371,7 @@ namespace EntityFrameworkCore.Data.Migrations
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Killaklowns",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Killaklowns"
},
new
{
@ -444,8 +380,7 @@ namespace EntityFrameworkCore.Data.Migrations
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Sol",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Sol"
},
new
{
@ -454,8 +389,7 @@ namespace EntityFrameworkCore.Data.Migrations
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 4,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "DEC",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "DEC"
},
new
{
@ -464,8 +398,7 @@ namespace EntityFrameworkCore.Data.Migrations
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Leopards",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Leopards"
},
new
{
@ -474,8 +407,7 @@ namespace EntityFrameworkCore.Data.Migrations
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Harlequins",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Harlequins"
},
new
{
@ -484,8 +416,7 @@ namespace EntityFrameworkCore.Data.Migrations
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 4,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Gladiators",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Gladiators"
},
new
{
@ -494,26 +425,10 @@ namespace EntityFrameworkCore.Data.Migrations
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 1,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Fiz-O",
Version = new Guid("00000000-0000-0000-0000-000000000000")
Name = "Fiz-O"
});
});
modelBuilder.Entity("EntityFrameworkCore.Domain.TeamsAndLeaguesView", b =>
{
b.Property<string>("LeagueName")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.ToTable((string)null);
b.ToView("vw_TeamsAndLeagues", (string)null);
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Match", b =>
{
b.HasOne("EntityFrameworkCore.Domain.Team", "AwayTeam")

View File

@ -1,6 +1,4 @@
using System.ComponentModel.DataAnnotations;
namespace EntityFrameworkCore.Domain;
namespace EntityFrameworkCore.Domain;
// Since C#11, you do not need to wrap in accolades anymore.
public abstract class BaseDomainModel
{
@ -9,12 +7,4 @@ public abstract class BaseDomainModel
public DateTime ModifiedDate { get; set;}
public string? CreatedBy { get; set; }
public string? ModifiedBy { get; set; }
// SQL Server method to setup concurrency column.
// [Timestamp]
// public byte[] Version { get; set; }
// SQLite (and other) method to setup concurrency column.
[ConcurrencyCheck]
public Guid Version { get; set; }
}

View File

@ -1,11 +1,7 @@
using System.ComponentModel.DataAnnotations;
namespace EntityFrameworkCore.Domain;
namespace EntityFrameworkCore.Domain;
// Since C#11, you do not need to wrap in accolades anymore.
public class Coach : BaseDomainModel
{
[MaxLength(100)]
[Required]
public string Name { get; set; } // Strings are automatically become VARCHAR database types.
public Team? Team { get; set; }
}

View File

@ -3,6 +3,5 @@
public class League : BaseDomainModel
{
public string? Name { get; set; }
public bool IsDeleted { get; set; }
public List<Team> Teams { get; set; } = new List<Team>() { };
}

View File

@ -61,12 +61,6 @@ Rollback to specific migration, use `list` command to see (Pending) changes:
To re-apply changes again, simply do a `database update` again. Beware that data will be lost.
When this error appears:
`Unable to create a 'DbContext' of type 'RuntimeType'. The exception 'The configuration file 'appsettings.json' was not found and is not optional.`
Then you should either provide an `appsettings.json` file in the project, or simply change the startup project.
## Links
* [Entity Framework - Database providers](https://learn.microsoft.com/en-us/ef/core/providers/?tabs=dotnet-core-cli)
@ -90,24 +84,6 @@ A list of installed NuGet packages in this application.
Note that the [Microsoft.EntityFrameworkCore.Tools](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Tools/9.0.3) is used for Powershell commands used in the Package Manager Console for Visual Studio and that [Microsoft.EntityFrameworkCore.Design](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Design/9.0.3) is used for cross-platform command tools.
### API project
[Microsoft.VisualStudio.Web.CodeGeneration.Design](https://www.nuget.org/packages/Microsoft.VisualStudio.Web.CodeGeneration.Design/9.0.0)
* `dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design --version 9.0.0`
[Microsoft.EntityFrameworkCore.Design](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Design/9.0.3)
* `dotnet add package Microsoft.EntityFrameworkCore.Design --version 9.0.3`
[Microsoft.EntityFrameworkCore.Sqlite](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Sqlite/9.0.3)
* `dotnet add package Microsoft.EntityFrameworkCore.Sqlite --version 9.0.3`
[Microsoft.EntityFrameworkCore.Tools](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Tools/9.0.3) *Required for aspnet-codegenerator cli tool.*
* `dotnet add package Microsoft.EntityFrameworkCore.Tools --version 9.0.3`
### Console project
[Microsoft.EntityFrameworkCore.Tools](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Tools/9.0.3)
@ -124,18 +100,6 @@ Note that the [Microsoft.EntityFrameworkCore.Tools](https://www.nuget.org/packag
* `dotnet add package Microsoft.EntityFrameworkCore.Sqlite --version 9.0.3`
[Microsoft.Extensions.Configuration](https://www.nuget.org/packages/Microsoft.Extensions.Configuration/9.0.3)
* `dotnet add package Microsoft.Extensions.Configuration --version 9.0.3`
[Microsoft.Extensions.Configuration.FileExtensions](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.FileExtensions/9.0.3)
* `dotnet add package Microsoft.Extensions.Configuration.FileExtensions --version 9.0.3`
[Microsoft.Extensions.Configuration.Json](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.Json/9.0.3)
* `dotnet add package Microsoft.Extensions.Configuration.Json --version 9.0.3`
## Tips for efficient querying
* Use indexes.
@ -187,39 +151,4 @@ This is the least recommended method of loading data. It requires the [Microsoft
* A **Team** has one **Coach** (1:1)
* **Matches** are played by many **Teams** (M:M)
You can use [EF Core Power Tools](https://marketplace.visualstudio.com/items?itemName=ErikEJ.EFCorePowerTools) to create diagrams.
## ASP.NET Core with Entity Framework Core
A web application will make connection to the database on demand, which is a scoped connection. When not using the database, the web application is in a disconnected state.
You cannot create a new context in a file, because a new connection needs to be established every time and also closed, when the database is no longer needed. Also, *no tracking* is recommended, because multiple people can manipulate data.
An Inversion of Control (IoC) container will be used to handle dependancy injection for the DbContext. And also the DbContext will need a constructor with parameters to initialize itself properly.
## Scaffolding
### Scaffolding tool
[ASP.NET Core code generator tool](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/tools/dotnet-aspnet-codegenerator?view=aspnetcore-9.0).
* `dotnet tool install -g dotnet-aspnet-codegenerator` or, if already installed: `update`
To run this tool:
* `dotnet aspnet-codegenerator controller -name TeamsController -async -api -m Team -dc DeadBallZoneLeagueDbContext -outDir Controllers -dbProvider sqlite`
Note that an issue may arise, related to this: https://github.com/dotnet/Scaffolding/issues/3145
## API
Since .NET 9, the OpenAPI standard has been defined. To view documentation of our API, Swagger UI can be installed separately.
See also: https://devblogs.microsoft.com/dotnet/dotnet9-openapi/
* [https://swagger.io/tools/swagger-ui/](https://swagger.io/tools/swagger-ui/)
* [Swagger UI installation](https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/usage/installation.md)
Or use:
* [install-swagger-tooling](https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-9.0&tabs=visual-studio-code#install-swagger-tooling)
You can use [EF Core Power Tools](https://marketplace.visualstudio.com/items?itemName=ErikEJ.EFCorePowerTools) to create diagrams.