ARCH-2: swap EF provider to Npgsql, drop SqlServer migrations + conn strings
- Microsoft.EntityFrameworkCore.SqlServer -> Npgsql.EntityFrameworkCore.PostgreSQL 10.0.2 - UseSqlServer -> UseNpgsql (Aspire-injected gerbilmanager connection) - Removed hardcoded sa connection strings from appsettings*.json - Deleted SqlServer-flavored initial migration (fresh Npgsql one follows; no prod data) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.8" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.2" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.2.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace GerbilManagerWebAPI.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationContext))]
|
||||
[Migration("20231030203950_initialCreate")]
|
||||
partial class initialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.12")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("GerbilManagerWebAPI.Models.Breeder", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Breeders", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("BreederId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("Gender")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<Guid?>("LitterId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BreederId");
|
||||
|
||||
b.HasIndex("LitterId");
|
||||
|
||||
b.ToTable("Gerbils", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GerbilManagerWebAPI.Models.Litter", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid?>("FatherId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("MotherId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int?>("Strength")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FatherId");
|
||||
|
||||
b.HasIndex("MotherId");
|
||||
|
||||
b.ToTable("Litters", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b =>
|
||||
{
|
||||
b.HasOne("GerbilManagerWebAPI.Models.Breeder", "Breeder")
|
||||
.WithMany()
|
||||
.HasForeignKey("BreederId");
|
||||
|
||||
b.HasOne("GerbilManagerWebAPI.Models.Litter", "Litter")
|
||||
.WithMany()
|
||||
.HasForeignKey("LitterId");
|
||||
|
||||
b.Navigation("Breeder");
|
||||
|
||||
b.Navigation("Litter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GerbilManagerWebAPI.Models.Litter", b =>
|
||||
{
|
||||
b.HasOne("GerbilManagerWebAPI.Models.Gerbil", "Father")
|
||||
.WithMany()
|
||||
.HasForeignKey("FatherId");
|
||||
|
||||
b.HasOne("GerbilManagerWebAPI.Models.Gerbil", "Mother")
|
||||
.WithMany()
|
||||
.HasForeignKey("MotherId");
|
||||
|
||||
b.Navigation("Father");
|
||||
|
||||
b.Navigation("Mother");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace GerbilManagerWebAPI.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class initialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Breeders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Breeders", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Gerbils",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Gender = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
LitterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
BreederId = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Gerbils", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Gerbils_Breeders_BreederId",
|
||||
column: x => x.BreederId,
|
||||
principalTable: "Breeders",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Litters",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Date = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
Strength = table.Column<int>(type: "int", nullable: true),
|
||||
FatherId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
MotherId = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Litters", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Litters_Gerbils_FatherId",
|
||||
column: x => x.FatherId,
|
||||
principalTable: "Gerbils",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_Litters_Gerbils_MotherId",
|
||||
column: x => x.MotherId,
|
||||
principalTable: "Gerbils",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Gerbils_BreederId",
|
||||
table: "Gerbils",
|
||||
column: "BreederId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Gerbils_LitterId",
|
||||
table: "Gerbils",
|
||||
column: "LitterId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Litters_FatherId",
|
||||
table: "Litters",
|
||||
column: "FatherId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Litters_MotherId",
|
||||
table: "Litters",
|
||||
column: "MotherId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Gerbils_Litters_LitterId",
|
||||
table: "Gerbils",
|
||||
column: "LitterId",
|
||||
principalTable: "Litters",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Gerbils_Breeders_BreederId",
|
||||
table: "Gerbils");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Gerbils_Litters_LitterId",
|
||||
table: "Gerbils");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Breeders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Litters");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Gerbils");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace GerbilManagerWebAPI.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationContext))]
|
||||
partial class ApplicationContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.12")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("GerbilManagerWebAPI.Models.Breeder", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Breeders", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("BreederId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("Gender")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<Guid?>("LitterId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BreederId");
|
||||
|
||||
b.HasIndex("LitterId");
|
||||
|
||||
b.ToTable("Gerbils", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GerbilManagerWebAPI.Models.Litter", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid?>("FatherId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("MotherId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int?>("Strength")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FatherId");
|
||||
|
||||
b.HasIndex("MotherId");
|
||||
|
||||
b.ToTable("Litters", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b =>
|
||||
{
|
||||
b.HasOne("GerbilManagerWebAPI.Models.Breeder", "Breeder")
|
||||
.WithMany()
|
||||
.HasForeignKey("BreederId");
|
||||
|
||||
b.HasOne("GerbilManagerWebAPI.Models.Litter", "Litter")
|
||||
.WithMany()
|
||||
.HasForeignKey("LitterId");
|
||||
|
||||
b.Navigation("Breeder");
|
||||
|
||||
b.Navigation("Litter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GerbilManagerWebAPI.Models.Litter", b =>
|
||||
{
|
||||
b.HasOne("GerbilManagerWebAPI.Models.Gerbil", "Father")
|
||||
.WithMany()
|
||||
.HasForeignKey("FatherId");
|
||||
|
||||
b.HasOne("GerbilManagerWebAPI.Models.Gerbil", "Mother")
|
||||
.WithMany()
|
||||
.HasForeignKey("MotherId");
|
||||
|
||||
b.Navigation("Father");
|
||||
|
||||
b.Navigation("Mother");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
builder.Services.AddDbContext<ApplicationContext>(opts => opts.UseSqlServer(builder.Configuration.GetConnectionString("sqlConnection")));
|
||||
builder.Services.AddDbContext<ApplicationContext>(opts => opts.UseNpgsql(builder.Configuration.GetConnectionString("gerbilmanager")));
|
||||
builder.Services.AddScoped<UnitOfWork>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
@@ -4,8 +4,5 @@
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"sqlConnection": "server=.; database=GerbilManagerDebug; User Id=sa;Password=StrongerThenYYou1;Encrypt=False;TrustServerCertificate=True"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,5 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"sqlConnection": "server=.; database=GerbilManagerDebug; User Id=sa;Password=StrongerThenYYou1;Encrypt=False;TrustServerCertificate=True"
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user