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
31 changes: 16 additions & 15 deletions SpeakingInBitsWeb/Data/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@
using Microsoft.EntityFrameworkCore;
using SpeakingInBitsWeb.Models;

namespace SpeakingInBitsWeb.Data
namespace SpeakingInBitsWeb.Data;

public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : IdentityDbContext<ApplicationUser>(options)
{
public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : IdentityDbContext<ApplicationUser>(options)
protected override void OnModelCreating(ModelBuilder builder)
{
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
base.OnModelCreating(builder);

builder.Entity<ApplicationUser>(entity =>
{
entity.Property(e => e.FirstName)
.HasMaxLength(50)
.IsRequired();
builder.Entity<ApplicationUser>(entity =>
{
entity.Property(e => e.FirstName)
.HasMaxLength(50)
.IsRequired();

entity.Property(e => e.LastName)
.HasMaxLength(50)
.IsRequired();
});
}
entity.Property(e => e.LastName)
.HasMaxLength(50)
.IsRequired();
});
}

public DbSet<Course> Courses { get; set; }
}

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

36 changes: 36 additions & 0 deletions SpeakingInBitsWeb/Data/Migrations/20251010012840_AddedCourse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace SpeakingInBitsWeb.Data.Migrations
{
/// <inheritdoc />
public partial class AddedCourse : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Courses",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
CourseCode = table.Column<string>(type: "nvarchar(8)", maxLength: 8, nullable: true),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Courses", x => x.Id);
});
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Courses");
}
}
}
Loading