Files
DugunSalonu/Models/dugunsalonuContext.cs
2025-08-11 11:22:31 +03:00

47 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DugunSalonu.Models
{
public class dugunsalonuContext : DbContext
{
public DbSet<Kullanici> kullanici { get; set; }
public DbSet<Salon> salon { get; set; }
public DbSet<Il> il { get; set; }
public DbSet<Ilce> ilce { get; set; }
public DbSet<Referans> referans { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Referans>()
.HasIndex(r => new { r.turu, r.kodu })
.IsUnique();
modelBuilder.Entity<Referans>().HasNoKey();
modelBuilder.Entity<Il>().HasMany<Ilce>(i => i.ilceler);
modelBuilder.Entity<Ilce>().HasOne<Il>(i => i.Il);
/*
// kts alanı için default değer
modelBuilder.Entity<Referans>()
.Property(r => r.kts)
.HasDefaultValueSql("NOW()");*/
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql("Server=edoysoft.com;Database=DugunSalonu;User Id=postgres;Password=MgC1453MgC;", b => b.EnableRetryOnFailure());
base.OnConfiguring(optionsBuilder);
}
}
}