add: ef core

This commit is contained in:
2025-09-03 16:31:58 -03:00
parent 3c2513a567
commit f7426e16d9
9 changed files with 287 additions and 1 deletions

View File

@@ -0,0 +1,65 @@
// <auto-generated />
using System;
using CampusWorkshops.Api.Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Workshop10_API.Migrations
{
[DbContext(typeof(WorkshopsDbContext))]
[Migration("20250903175616_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("CampusWorkshops.Api.Models.Workshop", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<int>("Capacity")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(1);
b.Property<string>("Description")
.HasMaxLength(2000)
.HasColumnType("TEXT");
b.Property<DateTimeOffset>("EndAt")
.HasColumnType("TEXT");
b.Property<bool>("IsOnline")
.HasColumnType("INTEGER");
b.Property<string>("Location")
.HasMaxLength(200)
.HasColumnType("TEXT");
b.Property<DateTimeOffset>("StartAt")
.HasColumnType("TEXT");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(120)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("StartAt");
b.ToTable("Workshops", (string)null);
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,45 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Workshop10_API.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Workshops",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
Title = table.Column<string>(type: "TEXT", maxLength: 120, nullable: false),
Description = table.Column<string>(type: "TEXT", maxLength: 2000, nullable: true),
StartAt = table.Column<DateTimeOffset>(type: "TEXT", nullable: false),
EndAt = table.Column<DateTimeOffset>(type: "TEXT", nullable: false),
Location = table.Column<string>(type: "TEXT", maxLength: 200, nullable: true),
Capacity = table.Column<int>(type: "INTEGER", nullable: false, defaultValue: 1),
IsOnline = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Workshops", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Workshops_StartAt",
table: "Workshops",
column: "StartAt");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Workshops");
}
}
}

View File

@@ -0,0 +1,62 @@
// <auto-generated />
using System;
using CampusWorkshops.Api.Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Workshop10_API.Migrations
{
[DbContext(typeof(WorkshopsDbContext))]
partial class WorkshopsDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("CampusWorkshops.Api.Models.Workshop", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<int>("Capacity")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(1);
b.Property<string>("Description")
.HasMaxLength(2000)
.HasColumnType("TEXT");
b.Property<DateTimeOffset>("EndAt")
.HasColumnType("TEXT");
b.Property<bool>("IsOnline")
.HasColumnType("INTEGER");
b.Property<string>("Location")
.HasMaxLength(200)
.HasColumnType("TEXT");
b.Property<DateTimeOffset>("StartAt")
.HasColumnType("TEXT");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(120)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("StartAt");
b.ToTable("Workshops", (string)null);
});
#pragma warning restore 612, 618
}
}
}