Files
DugunSalonu/Models/dugunsalonuContext.cs
2025-08-08 12:31:51 +03:00

44 lines
1.6 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
{
internal class dugunsalonuContext:DbContext
{
public DbSet<Kullanici> kullanici { get; set; }
public DbSet<Salon> salon { get; set; }
public DbSet<Il> il { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql("Server=edoysoft.com;Database=DugunSalonu;User Id=postgres;Password=MgC1453MgC;", b => b.EnableRetryOnFailure());
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());
}
}
}
}