CKN.Sdk.EntityFramework
0.0.0-alpha.0.55
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
<PackageReference Include="CKN.Sdk.EntityFramework" Version="0.0.0-alpha.0.55" />
<PackageVersion Include="CKN.Sdk.EntityFramework" Version="0.0.0-alpha.0.55" />
<PackageReference Include="CKN.Sdk.EntityFramework" />
paket add CKN.Sdk.EntityFramework --version 0.0.0-alpha.0.55
#r "nuget: CKN.Sdk.EntityFramework, 0.0.0-alpha.0.55"
#:package CKN.Sdk.EntityFramework@0.0.0-alpha.0.55
#addin nuget:?package=CKN.Sdk.EntityFramework&version=0.0.0-alpha.0.55&prerelease
#tool nuget:?package=CKN.Sdk.EntityFramework&version=0.0.0-alpha.0.55&prerelease
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.EntityFrameworkprojelerinde Repository Pattern zorunlu mudur? - Cevap: Hayır, EF Core'un içindeki
DbContextbir Unit of Work,DbSetise bir Repository pattern'idir. Çoğu modern CQRS/DDD projesinde doğrudanDbContextkullanı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 | Versions 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. |
-
net10.0
- CKN.Sdk.Core (>= 0.0.0-alpha.0.55)
- MassTransit.EntityFrameworkCore (>= 9.2.1)
- Microsoft.AspNetCore.Identity.EntityFrameworkCore (>= 10.0.11)
- Microsoft.EntityFrameworkCore (>= 10.0.11)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.11)
-
net8.0
- CKN.Sdk.Core (>= 0.0.0-alpha.0.55)
- MassTransit.EntityFrameworkCore (>= 8.3.1)
- Microsoft.AspNetCore.Identity.EntityFrameworkCore (>= 8.0.0)
- Microsoft.EntityFrameworkCore (>= 8.0.0)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.0)
-
net9.0
- CKN.Sdk.Core (>= 0.0.0-alpha.0.55)
- MassTransit.EntityFrameworkCore (>= 9.2.1)
- Microsoft.AspNetCore.Identity.EntityFrameworkCore (>= 9.0.2)
- Microsoft.EntityFrameworkCore (>= 9.0.2)
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.2)
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 |