47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
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);
|
||
}
|
||
|
||
|
||
}
|
||
}
|