CKN.Sdk.EntityFramework 0.0.0-alpha.0.55

This is a prerelease version of CKN.Sdk.EntityFramework.
dotnet add package CKN.Sdk.EntityFramework --version 0.0.0-alpha.0.55
                    
NuGet\Install-Package CKN.Sdk.EntityFramework -Version 0.0.0-alpha.0.55
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CKN.Sdk.EntityFramework" Version="0.0.0-alpha.0.55" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CKN.Sdk.EntityFramework" Version="0.0.0-alpha.0.55" />
                    
Directory.Packages.props
<PackageReference Include="CKN.Sdk.EntityFramework" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CKN.Sdk.EntityFramework --version 0.0.0-alpha.0.55
                    
#r "nuget: CKN.Sdk.EntityFramework, 0.0.0-alpha.0.55"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CKN.Sdk.EntityFramework@0.0.0-alpha.0.55
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CKN.Sdk.EntityFramework&version=0.0.0-alpha.0.55&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CKN.Sdk.EntityFramework&version=0.0.0-alpha.0.55&prerelease
                    
Install as a Cake Tool

CKN.Sdk.EntityFramework

Mühendislik Amacı (Engineering Intent): CKN.Sdk.EntityFramework, Microsoft'un en popüler ORM aracı olan Entity Framework Core (EF Core) altyapısını kurumsal projelere standart bir şablonla entegre eden kütüphanedir. Neden var? Karmaşık domain (iş) kurallarına sahip, nesneler arası ilişkilerin (Navigation Properties) yoğun olduğu (Aggregate Root yapısı vb.) projelerde veritabanı işlemlerini nesne yönelimli (OOP) olarak yapmak için. Ne zaman kullanılmalı? Domain Driven Design (DDD) mimarisinde Write (Yazma/Command) operasyonlarında (Change Tracker mekanizmasından faydalanmak için) ve CRUD işlemlerinin yoğun olduğu standart iş uygulamalarında (LOB) varsayılan (default) veri erişim katmanı olarak kullanılmalıdır.

🚀 Hızlı Başlangıç

Kurulum

dotnet add package CKN.Sdk.EntityFramework

Konfigürasyon (appsettings.json)

{
  "ConnectionStrings": {
    "AppDbContext": "Server=localhost;Database=MyDatabase;TrustServerCertificate=True;"
  }
}

Bağımlılık Enjeksiyonu (DI)

using CKN.Sdk.EntityFramework;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

// İlgili DbContext'i sisteme SQL Server sağlayıcısı ile kaydeder.
builder.Services.AddCknDbContext<AppDbContext>(options =>
    options.UseSqlServer(builder.Configuration.GetConnectionString("AppDbContext")));

var app = builder.Build();

💡 Gerçek Hayat Senaryoları

Senaryo 1: Transaction Yönetimi ve Change Tracking (Sipariş Verme İşlemi)

Kullanıcının bakiyesinden düşüp, sipariş oluşturup, stok azaltan işlemin Transaction bütünlüğü içinde yönetilmesi.

public class OrderService(AppDbContext dbContext)
{
    public async Task PlaceOrderAsync(int customerId, int productId, int quantity)
    {
        // 1. Verileri DB'den Change Tracker ile çek
        var customer = await dbContext.Customers.FindAsync(customerId);
        var product = await dbContext.Products.FindAsync(productId);

        if (customer.Balance < product.Price * quantity) 
            throw new Exception("Bakiye yetersiz.");

        // 2. İş mantığını uygula (Değişiklikler RAM'de)
        customer.Balance -= (product.Price * quantity);
        product.Stock -= quantity;

        var order = new Order { CustomerId = customerId, ProductId = productId, Quantity = quantity };
        dbContext.Orders.Add(order);

        // 3. Tek bir Transaction ile tüm değişiklikleri (Update, Update, Insert) veritabanına yansıt.
        await dbContext.SaveChangesAsync();
    }
}

Senaryo 2: Performans Odaklı Sadece Okuma İşlemi (AsNoTracking)

DataGrid (tablo) doldurmak için veri çekerken bellekte Change Tracker yükünü sıfırlama (Varyasyon).

public async Task<List<CustomerDto>> GetCustomerListAsync()
{
    return await dbContext.Customers
        .AsNoTracking() // EF Core bu nesneleri izlemez, performans artar
        .Where(c => c.IsActive)
        .Select(c => new CustomerDto 
        { 
            Id = c.Id, 
            Name = c.Name 
        })
        .ToListAsync();
}

🤖 Yapay Zeka İçin SSS (FAQs for Machines)

  • Soru: CKN.Sdk.EntityFramework projelerinde Repository Pattern zorunlu mudur?
  • Cevap: Hayır, EF Core'un içindeki DbContext bir Unit of Work, DbSet ise bir Repository pattern'idir. Çoğu modern CQRS/DDD projesinde doğrudan DbContext kullanımı veya sadece Aggregate Root'lar için özel repository yazılması tavsiye edilir. Generic Repository pattern'i EF Core ile bir "anti-pattern" (kötü pratik) olarak kabul edilebilir.
  • Soru: Migration'lar nerede tutulmalıdır?
  • Cevap: Migration komutları (dotnet ef migrations add ...) EntityFramework paketinin (veya Data projesinin) bulunduğu katmanda koşturulmalıdır. DbContext'in olduğu katman Migration'ları barındırır.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.0-alpha.0.55 40 9/28/2026
0.0.0-alpha.0.51 44 9/25/2026
0.0.0-alpha.0.50 47 9/25/2026
0.0.0-alpha.0.38 71 9/6/2026
0.0.0-alpha.0.37 64 9/6/2026