From 5c7bb2c3998247297a7181c730363c780d55b406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?erdem=20demircio=C4=9Flu?= Date: Mon, 11 Aug 2025 11:22:31 +0300 Subject: [PATCH] =?UTF-8?q?g=C3=BCncelleme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Migrations/20250811081119_mig10.Designer.cs | 210 ++++++++++++++++ Migrations/20250811081119_mig10.cs | 65 +++++ Migrations/20250811082022_mig11.Designer.cs | 230 ++++++++++++++++++ Migrations/20250811082022_mig11.cs | 39 +++ Migrations/dugunsalonuContextModelSnapshot.cs | 44 ++-- Models/Il.cs | 3 +- Models/Ilce.cs | 18 +- Models/Kullanici.cs | 6 +- Models/Referans.cs | 10 +- Models/dugunsalonuContext.cs | 29 +-- 10 files changed, 599 insertions(+), 55 deletions(-) create mode 100644 Migrations/20250811081119_mig10.Designer.cs create mode 100644 Migrations/20250811081119_mig10.cs create mode 100644 Migrations/20250811082022_mig11.Designer.cs create mode 100644 Migrations/20250811082022_mig11.cs diff --git a/Migrations/20250811081119_mig10.Designer.cs b/Migrations/20250811081119_mig10.Designer.cs new file mode 100644 index 0000000..ecbc901 --- /dev/null +++ b/Migrations/20250811081119_mig10.Designer.cs @@ -0,0 +1,210 @@ +// +using System; +using DugunSalonu.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DugunSalonu.Migrations +{ + [DbContext(typeof(dugunsalonuContext))] + [Migration("20250811081119_mig10")] + partial class mig10 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("DugunSalonu.Models.Il", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); + + b.Property("adi") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("id"); + + b.ToTable("il"); + }); + + modelBuilder.Entity("DugunSalonu.Models.Ilce", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); + + b.Property("ILid") + .HasColumnType("integer") + .HasColumnName("ilid"); + + b.Property("adi") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("id"); + + b.ToTable("ilce"); + }); + + modelBuilder.Entity("DugunSalonu.Models.Kullanici", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); + + b.Property("adi") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("admin") + .HasColumnType("boolean"); + + b.Property("aktif") + .HasColumnType("boolean"); + + b.Property("ceptel") + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("eposta") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("kullaniciadi") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("parola") + .IsRequired() + .HasColumnType("text"); + + b.Property("soyadi") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("id"); + + b.ToTable("kullanici"); + }); + + modelBuilder.Entity("DugunSalonu.Models.Referans", b => + { + b.Property("adi") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("aktif") + .HasColumnType("boolean"); + + b.Property("id") + .HasColumnType("integer"); + + b.Property("kk") + .HasColumnType("integer"); + + b.Property("kodu") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("kts") + .HasColumnType("timestamp with time zone"); + + b.Property("turu") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasIndex("turu", "kodu") + .IsUnique(); + + b.ToTable("referans"); + }); + + modelBuilder.Entity("DugunSalonu.Models.Salon", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); + + b.Property("CepTel") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("adi") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("character varying(150)"); + + b.Property("adres") + .HasMaxLength(250) + .HasColumnType("character varying(250)"); + + b.Property("eposta") + .IsRequired() + .HasColumnType("text"); + + b.Property("ilceid") + .HasColumnType("integer"); + + b.Property("ilid") + .HasColumnType("integer"); + + b.Property("telefon") + .HasColumnType("text"); + + b.Property("vergidairesi") + .HasColumnType("text"); + + b.Property("verginumarasi") + .HasColumnType("text"); + + b.Property("webadres") + .HasColumnType("text"); + + b.HasKey("id"); + + b.HasIndex("ilid"); + + b.ToTable("salon"); + }); + + modelBuilder.Entity("DugunSalonu.Models.Salon", b => + { + b.HasOne("DugunSalonu.Models.Il", "il") + .WithMany() + .HasForeignKey("ilid"); + + b.Navigation("il"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20250811081119_mig10.cs b/Migrations/20250811081119_mig10.cs new file mode 100644 index 0000000..5442956 --- /dev/null +++ b/Migrations/20250811081119_mig10.cs @@ -0,0 +1,65 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DugunSalonu.Migrations +{ + /// + public partial class mig10 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_referans", + table: "referans"); + + migrationBuilder.AlterColumn( + name: "kts", + table: "referans", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldDefaultValueSql: "NOW()"); + + migrationBuilder.AlterColumn( + name: "id", + table: "referans", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer") + .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "kts", + table: "referans", + type: "timestamp with time zone", + nullable: false, + defaultValueSql: "NOW()", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "id", + table: "referans", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer") + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + migrationBuilder.AddPrimaryKey( + name: "PK_referans", + table: "referans", + column: "id"); + } + } +} diff --git a/Migrations/20250811082022_mig11.Designer.cs b/Migrations/20250811082022_mig11.Designer.cs new file mode 100644 index 0000000..b479f0f --- /dev/null +++ b/Migrations/20250811082022_mig11.Designer.cs @@ -0,0 +1,230 @@ +// +using System; +using DugunSalonu.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DugunSalonu.Migrations +{ + [DbContext(typeof(dugunsalonuContext))] + [Migration("20250811082022_mig11")] + partial class mig11 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("DugunSalonu.Models.Il", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); + + b.Property("adi") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("id"); + + b.ToTable("il"); + }); + + modelBuilder.Entity("DugunSalonu.Models.Ilce", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); + + b.Property("ILid") + .HasColumnType("integer") + .HasColumnName("ilid"); + + b.Property("adi") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("id"); + + b.HasIndex("ILid"); + + b.ToTable("ilce"); + }); + + modelBuilder.Entity("DugunSalonu.Models.Kullanici", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); + + b.Property("adi") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("admin") + .HasColumnType("boolean"); + + b.Property("aktif") + .HasColumnType("boolean"); + + b.Property("ceptel") + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("eposta") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("kullaniciadi") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("parola") + .IsRequired() + .HasColumnType("text"); + + b.Property("soyadi") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("id"); + + b.ToTable("kullanici"); + }); + + modelBuilder.Entity("DugunSalonu.Models.Referans", b => + { + b.Property("adi") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("aktif") + .HasColumnType("boolean"); + + b.Property("id") + .HasColumnType("integer"); + + b.Property("kk") + .HasColumnType("integer"); + + b.Property("kodu") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("kts") + .HasColumnType("timestamp with time zone"); + + b.Property("turu") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasIndex("turu", "kodu") + .IsUnique(); + + b.ToTable("referans"); + }); + + modelBuilder.Entity("DugunSalonu.Models.Salon", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); + + b.Property("CepTel") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("adi") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("character varying(150)"); + + b.Property("adres") + .HasMaxLength(250) + .HasColumnType("character varying(250)"); + + b.Property("eposta") + .IsRequired() + .HasColumnType("text"); + + b.Property("ilceid") + .HasColumnType("integer"); + + b.Property("ilid") + .HasColumnType("integer"); + + b.Property("telefon") + .HasColumnType("text"); + + b.Property("vergidairesi") + .HasColumnType("text"); + + b.Property("verginumarasi") + .HasColumnType("text"); + + b.Property("webadres") + .HasColumnType("text"); + + b.HasKey("id"); + + b.HasIndex("ilid"); + + b.ToTable("salon"); + }); + + modelBuilder.Entity("DugunSalonu.Models.Ilce", b => + { + b.HasOne("DugunSalonu.Models.Il", "Il") + .WithMany("ilceler") + .HasForeignKey("ILid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Il"); + }); + + modelBuilder.Entity("DugunSalonu.Models.Salon", b => + { + b.HasOne("DugunSalonu.Models.Il", "il") + .WithMany("salons") + .HasForeignKey("ilid"); + + b.Navigation("il"); + }); + + modelBuilder.Entity("DugunSalonu.Models.Il", b => + { + b.Navigation("ilceler"); + + b.Navigation("salons"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20250811082022_mig11.cs b/Migrations/20250811082022_mig11.cs new file mode 100644 index 0000000..2cf9782 --- /dev/null +++ b/Migrations/20250811082022_mig11.cs @@ -0,0 +1,39 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DugunSalonu.Migrations +{ + /// + public partial class mig11 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateIndex( + name: "IX_ilce_ilid", + table: "ilce", + column: "ilid"); + + migrationBuilder.AddForeignKey( + name: "FK_ilce_il_ilid", + table: "ilce", + column: "ilid", + principalTable: "il", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ilce_il_ilid", + table: "ilce"); + + migrationBuilder.DropIndex( + name: "IX_ilce_ilid", + table: "ilce"); + } + } +} diff --git a/Migrations/dugunsalonuContextModelSnapshot.cs b/Migrations/dugunsalonuContextModelSnapshot.cs index 74d9955..a253d6f 100644 --- a/Migrations/dugunsalonuContextModelSnapshot.cs +++ b/Migrations/dugunsalonuContextModelSnapshot.cs @@ -47,16 +47,19 @@ namespace DugunSalonu.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); + b.Property("ILid") + .HasColumnType("integer") + .HasColumnName("ilid"); + b.Property("adi") .IsRequired() .HasMaxLength(50) .HasColumnType("character varying(50)"); - b.Property("ilid") - .HasColumnType("integer"); - b.HasKey("id"); + b.HasIndex("ILid"); + b.ToTable("ilce"); }); @@ -108,12 +111,6 @@ namespace DugunSalonu.Migrations modelBuilder.Entity("DugunSalonu.Models.Referans", b => { - b.Property("id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); - b.Property("adi") .IsRequired() .HasMaxLength(50) @@ -122,6 +119,9 @@ namespace DugunSalonu.Migrations b.Property("aktif") .HasColumnType("boolean"); + b.Property("id") + .HasColumnType("integer"); + b.Property("kk") .HasColumnType("integer"); @@ -131,17 +131,13 @@ namespace DugunSalonu.Migrations .HasColumnType("character varying(20)"); b.Property("kts") - .ValueGeneratedOnAdd() - .HasColumnType("timestamp with time zone") - .HasDefaultValueSql("NOW()"); + .HasColumnType("timestamp with time zone"); b.Property("turu") .IsRequired() .HasMaxLength(50) .HasColumnType("character varying(50)"); - b.HasKey("id"); - b.HasIndex("turu", "kodu") .IsUnique(); @@ -199,14 +195,32 @@ namespace DugunSalonu.Migrations b.ToTable("salon"); }); + modelBuilder.Entity("DugunSalonu.Models.Ilce", b => + { + b.HasOne("DugunSalonu.Models.Il", "Il") + .WithMany("ilceler") + .HasForeignKey("ILid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Il"); + }); + modelBuilder.Entity("DugunSalonu.Models.Salon", b => { b.HasOne("DugunSalonu.Models.Il", "il") - .WithMany() + .WithMany("salons") .HasForeignKey("ilid"); b.Navigation("il"); }); + + modelBuilder.Entity("DugunSalonu.Models.Il", b => + { + b.Navigation("ilceler"); + + b.Navigation("salons"); + }); #pragma warning restore 612, 618 } } diff --git a/Models/Il.cs b/Models/Il.cs index 67d6939..9168ed4 100644 --- a/Models/Il.cs +++ b/Models/Il.cs @@ -16,6 +16,7 @@ namespace DugunSalonu.Models public int id { get; set; } public string adi { get; set; } - ICollection? salons { get; set; } + public ICollection? salons { get; set; } + public ICollection? ilceler { get; set; } } } diff --git a/Models/Ilce.cs b/Models/Ilce.cs index 4821d0f..fb3e118 100644 --- a/Models/Ilce.cs +++ b/Models/Ilce.cs @@ -1,18 +1,16 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DugunSalonu.Models { - internal class Ilce + [Table("ilce")] + public class Ilce { - public Ilce() - { - il = new HashSet(); - } [Key] public int id { get; set; } @@ -20,10 +18,10 @@ namespace DugunSalonu.Models [MaxLength(50)] public required string adi { get; set; } [Required] - public required int ilid { get; set; } - ICollection? il { get; set; } - - ICollection? ilce { get; set; } - + [Column("ilid")] + public required int ILid { get; set; } + Salon? il { get; set; } + ICollection? salon { get; set; } + public Il? Il { get; set; } } } diff --git a/Models/Kullanici.cs b/Models/Kullanici.cs index 773842f..5c582c7 100644 --- a/Models/Kullanici.cs +++ b/Models/Kullanici.cs @@ -8,18 +8,18 @@ using System.Threading.Tasks; namespace DugunSalonu.Models { - internal class Kullanici + public class Kullanici { [Key] public int id { get; set; } - + [MaxLength(50), MinLength(5)] [Required] public required string kullaniciadi { get; set; } [Required] [MaxLength(50)] public required string adi { get; set; } - + [Required] [MaxLength(50)] public required string soyadi { get; set; } diff --git a/Models/Referans.cs b/Models/Referans.cs index afdf5c8..a78bc38 100644 --- a/Models/Referans.cs +++ b/Models/Referans.cs @@ -9,14 +9,14 @@ using System.Windows.Forms.VisualStyles; namespace DugunSalonu.Models { - public class Referans + public class Referans { [Key] public int id { get; set; } [Required] [MaxLength(50)] - public required string turu { get; set; } + public required string turu { get; set; } [Required] [MaxLength(20)] public required string kodu { get; set; } @@ -24,12 +24,12 @@ namespace DugunSalonu.Models [MaxLength(50)] public required string adi { get; set; } [Required] - public required DateTime kts { get; set; } + public required DateTime kts { get; set; } = DateTime.UtcNow; [Required] - public required int kk { get; set; } + public required int kk { get; set; } public bool aktif { get; set; } - + } } diff --git a/Models/dugunsalonuContext.cs b/Models/dugunsalonuContext.cs index 3409d51..a275a6a 100644 --- a/Models/dugunsalonuContext.cs +++ b/Models/dugunsalonuContext.cs @@ -8,12 +8,12 @@ using System.Threading.Tasks; namespace DugunSalonu.Models { - internal class dugunsalonuContext:DbContext + public class dugunsalonuContext : DbContext { public DbSet kullanici { get; set; } - public DbSet salon { get; set; } - public DbSet il { get; set; } + public DbSet salon { get; set; } + public DbSet il { get; set; } public DbSet ilce { get; set; } @@ -26,11 +26,14 @@ namespace DugunSalonu.Models modelBuilder.Entity() .HasIndex(r => new { r.turu, r.kodu }) .IsUnique(); - + modelBuilder.Entity().HasNoKey(); + modelBuilder.Entity().HasMany(i => i.ilceler); + modelBuilder.Entity().HasOne(i => i.Il); + /* // kts alanı için default değer modelBuilder.Entity() .Property(r => r.kts) - .HasDefaultValueSql("NOW()"); + .HasDefaultValueSql("NOW()");*/ } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { @@ -38,22 +41,6 @@ namespace DugunSalonu.Models base.OnConfiguring(optionsBuilder); } - /*protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); - foreach (var entityType in modelBuilder.Model.GetEntityTypes()) - { - // Sütun isimlerini büyük harfe dönüştür - foreach (var property in entityType.GetProperties()) - { - var columnName = property.GetColumnName(StoreObjectIdentifier.Table(entityType.GetTableName(), entityType.GetSchema())); - // property.SetColumnName(Encoding.ASCII.GetString(columnName.ToLower())); - } - - // İsteğe bağlı: Tablo isimlerini de büyük harfe dönüştür (eğer istiyorsanız) - entityType.SetTableName(entityType.GetTableName().ToLower()); - } - }*/ } }