diff --git a/USEntryCoach.Server/Data/TestModel.cs b/USEntryCoach.Server/Data/TestModel.cs deleted file mode 100644 index 5a85e29..0000000 --- a/USEntryCoach.Server/Data/TestModel.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Microsoft.EntityFrameworkCore; - -namespace USEntryCoach.Server.Data; - -public class BloggingContext : DbContext -{ - public DbSet Blogs { get; set; } - public DbSet Posts { get; set; } - - - public BloggingContext (DbContextOptions options) - : base(options) - { - } - - //public string ConnectionString { get; } = configuration.GetConnectionString("Default") ?? "No connection string"; - - //protected override void OnConfiguring(DbContextOptionsBuilder options) => options.UseNpgsql(ConnectionString); -} - -public class Blog -{ - public int BlogId { get; set; } - public string Url { get; set; } - - public List Posts { get; } = new(); -} - -public class Post -{ - public int PostId { get; set; } - public string Title { get; set; } - public string Content { get; set; } - - public int BlogId { get; set; } - public Blog Blog { get; set; } -} diff --git a/USEntryCoach.Server/Migrations/20250527114315_Initial.Designer.cs b/USEntryCoach.Server/Migrations/20250527114315_Initial.Designer.cs deleted file mode 100644 index 4ae12e0..0000000 --- a/USEntryCoach.Server/Migrations/20250527114315_Initial.Designer.cs +++ /dev/null @@ -1,88 +0,0 @@ -// -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using USEntryCoach.Server.Data; - -#nullable disable - -namespace USEntryCoach.Server.Migrations -{ - [DbContext(typeof(BloggingContext))] - [Migration("20250527114315_Initial")] - partial class Initial - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "9.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("USEntryCoach.Server.Data.Blog", b => - { - b.Property("BlogId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BlogId")); - - b.Property("Url") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("BlogId"); - - b.ToTable("Blogs"); - }); - - modelBuilder.Entity("USEntryCoach.Server.Data.Post", b => - { - b.Property("PostId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PostId")); - - b.Property("BlogId") - .HasColumnType("integer"); - - b.Property("Content") - .IsRequired() - .HasColumnType("text"); - - b.Property("Title") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("PostId"); - - b.HasIndex("BlogId"); - - b.ToTable("Posts"); - }); - - modelBuilder.Entity("USEntryCoach.Server.Data.Post", b => - { - b.HasOne("USEntryCoach.Server.Data.Blog", "Blog") - .WithMany("Posts") - .HasForeignKey("BlogId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Blog"); - }); - - modelBuilder.Entity("USEntryCoach.Server.Data.Blog", b => - { - b.Navigation("Posts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/USEntryCoach.Server/Migrations/20250527114315_Initial.cs b/USEntryCoach.Server/Migrations/20250527114315_Initial.cs deleted file mode 100644 index 937d1d8..0000000 --- a/USEntryCoach.Server/Migrations/20250527114315_Initial.cs +++ /dev/null @@ -1,64 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace USEntryCoach.Server.Migrations -{ - /// - public partial class Initial : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Blogs", - columns: table => new - { - BlogId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Url = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Blogs", x => x.BlogId); - }); - - migrationBuilder.CreateTable( - name: "Posts", - columns: table => new - { - PostId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Title = table.Column(type: "text", nullable: false), - Content = table.Column(type: "text", nullable: false), - BlogId = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Posts", x => x.PostId); - table.ForeignKey( - name: "FK_Posts_Blogs_BlogId", - column: x => x.BlogId, - principalTable: "Blogs", - principalColumn: "BlogId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_Posts_BlogId", - table: "Posts", - column: "BlogId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Posts"); - - migrationBuilder.DropTable( - name: "Blogs"); - } - } -} diff --git a/USEntryCoach.Server/Migrations/BloggingContextModelSnapshot.cs b/USEntryCoach.Server/Migrations/BloggingContextModelSnapshot.cs deleted file mode 100644 index 2871da6..0000000 --- a/USEntryCoach.Server/Migrations/BloggingContextModelSnapshot.cs +++ /dev/null @@ -1,85 +0,0 @@ -// -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using USEntryCoach.Server.Data; - -#nullable disable - -namespace USEntryCoach.Server.Migrations -{ - [DbContext(typeof(BloggingContext))] - partial class BloggingContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "9.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("USEntryCoach.Server.Data.Blog", b => - { - b.Property("BlogId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BlogId")); - - b.Property("Url") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("BlogId"); - - b.ToTable("Blogs"); - }); - - modelBuilder.Entity("USEntryCoach.Server.Data.Post", b => - { - b.Property("PostId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PostId")); - - b.Property("BlogId") - .HasColumnType("integer"); - - b.Property("Content") - .IsRequired() - .HasColumnType("text"); - - b.Property("Title") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("PostId"); - - b.HasIndex("BlogId"); - - b.ToTable("Posts"); - }); - - modelBuilder.Entity("USEntryCoach.Server.Data.Post", b => - { - b.HasOne("USEntryCoach.Server.Data.Blog", "Blog") - .WithMany("Posts") - .HasForeignKey("BlogId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Blog"); - }); - - modelBuilder.Entity("USEntryCoach.Server.Data.Blog", b => - { - b.Navigation("Posts"); - }); -#pragma warning restore 612, 618 - } - } -}