Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Entity Framework Core kapsamlı eğitim projesi - Web API, LINQ, async/await, Serilog, Custom Extensions ve EF Core best practices örnekleri içeren modern .NET 8.0 uygulaması

Notifications You must be signed in to change notification settings

bircany/EFCoreTutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EFCore Tutorial Projesi

Bu proje, Entity Framework Core'un temel ve gelişmiş özelliklerini öğrenmek için tasarlanmış kapsamlı bir eğitim projesidir.

🚀 Kullanılan Teknolojiler

Backend Framework

  • .NET 8.0 - En güncel .NET sürümü
  • ASP.NET Core Web API - RESTful API geliştirme

Veritabanı ve ORM

  • Entity Framework Core 8.0.5 - Modern ORM framework
  • Microsoft SQL Server - İlişkisel veritabanı
  • EF Core Design Tools - Migration ve model oluşturma araçları
  • EF Core Tools - CLI komutları için

Logging ve Monitoring

  • Serilog - Yapılandırılabilir logging framework
  • Console ve Debug logging - Geliştirme ortamı için

API Documentation

  • Swagger/OpenAPI - API dokümantasyonu ve test arayüzü

Asenkron Programlama

  • async/await - Asenkron operasyonlar
  • Task - Asenkron görev yönetimi
  • IQueryable - LINQ sorguları için

LINQ ve Custom Extensions

  • LINQ (Language Integrated Query) - Veri sorgulama
  • Custom LINQ Extensions - Özel extension metodları
  • IEnumerable - Koleksiyon işlemleri

📁 Proje Yapısı

EFCoreTutorial/
├── src/
│   ├── EFCoreTutorial.WebApi/          # Web API katmanı
│   │   ├── Controllers/                # API Controller'ları
│   │   ├── Program.cs                  # Uygulama başlangıç noktası
│   │   └── appsettings.json           # Konfigürasyon dosyaları
│   ├── EFCoreTutorial.Data/            # Veri erişim katmanı
│   │   ├── Context/                    # DbContext sınıfları
│   │   ├── Models/                     # Entity modelleri
│   │   └── Migrations/                 # EF Core migrations
│   └── EFCoreTutorial.Common/          # Ortak kullanılan sınıflar
│       └── StringConstants.cs         # Sabit değerler
├── TBCustomLinq/                       # Custom LINQ örnekleri
│   ├── LinQExtensions.cs              # Özel extension metodları
│   └── UserModel.cs                   # Örnek model
└── EFCoreTutorial.sln                 # Solution dosyası

🏗️ Mimari Katmanlar

1. Web API Katmanı (EFCoreTutorial.WebApi)

  • Controllers: REST API endpoint'leri
  • Dependency Injection: Service container konfigürasyonu
  • Middleware: Serilog, Swagger, CORS konfigürasyonu
  • Async/Await: Asenkron controller metodları

2. Data Katmanı (EFCoreTutorial.Data)

  • DbContext: Entity Framework Core context sınıfı
  • Entity Models: Veritabanı tablolarını temsil eden sınıflar
  • Relationships: One-to-One, One-to-Many, Many-to-Many ilişkiler
  • Fluent API: Model konfigürasyonu

3. Common Katmanı (EFCoreTutorial.Common)

  • Constants: Sabit değerler ve connection string'ler
  • Shared Models: Ortak kullanılan model sınıfları

🔧 EF Core Özellikleri

Entity Relationships

  • One-to-One: Student ↔ StudentAddress
  • One-to-Many: Student ↔ Books
  • Many-to-Many: Student ↔ Courses

Loading Strategies

  • Eager Loading: Include() ile ilişkili verilerin yüklenmesi
  • Lazy Loading: Proxy kullanarak otomatik yükleme
  • Explicit Loading: Load() ile manuel yükleme

Query Operations

  • LINQ Queries: Where, OrderBy, Select, FirstOrDefault
  • Async Operations: ToListAsync(), FirstOrDefaultAsync()
  • Filtering: Dinamik filtreleme işlemleri
  • Projection: Select ile veri dönüşümü

Model Configuration

  • Fluent API: OnModelCreating ile detaylı konfigürasyon
  • Column Mapping: Özel kolon isimleri ve tipleri
  • Constraints: Foreign key ve index tanımları
  • Default Values: Varsayılan değerler

🛠️ Kurulum ve Çalıştırma

Gereksinimler

  • .NET 8.0 SDK
  • SQL Server (Express veya üzeri)
  • Visual Studio 2022 veya VS Code

Adımlar

  1. Projeyi klonlayın
  2. Connection string'i StringConstants.cs dosyasında güncelleyin
  3. Migration'ları çalıştırın:
    dotnet ef database update
  4. Projeyi çalıştırın:
    dotnet run --project src/EFCoreTutorial.WebApi

📚 Öğrenilen Konseptler

Entity Framework Core

  • DbContext yaşam döngüsü
  • Entity konfigürasyonu
  • Migration yönetimi
  • İlişki tanımları
  • Sorgu optimizasyonu

Asenkron Programlama

  • async/await pattern
  • Task kullanımı
  • Asenkron veritabanı operasyonları
  • Performance optimizasyonu

LINQ ve Custom Extensions

  • Extension method yazımı
  • IEnumerable operasyonları
  • Custom filtering ve projection
  • Method chaining

Web API Best Practices

  • RESTful endpoint tasarımı
  • Dependency injection
  • Middleware konfigürasyonu
  • Error handling

🔍 API Endpoints

Student Controller

  • GET /api/student - Öğrenci listesi
  • POST /api/student - Yeni öğrenci ekleme
  • PUT /api/student - Öğrenci güncelleme
  • DELETE /api/student/{id} - Öğrenci silme

📝 Örnek Kullanımlar

Eager Loading

var students = await context.Students
    .Include(s => s.Books)
    .Include(s => s.Address)
    .ToListAsync();

Custom LINQ Extension

var evenIdUsers = users.TBWhere_EvenId();
var gmailUsers = users.TBWhere_GmailUsers();

Dynamic Filtering

var students = context.Students.AsQueryable();

if (!string.IsNullOrEmpty(filter.FirstName))
    students = students.Where(s => s.FirstName == filter.FirstName);

🤝 Katkıda Bulunma

  1. Fork yapın
  2. Feature branch oluşturun (git checkout -b feature/amazing-feature)
  3. Commit yapın (git commit -m 'Add amazing feature')
  4. Push yapın (git push origin feature/amazing-feature)
  5. Pull Request oluşturun

📄 Lisans

Bu proje eğitim amaçlı oluşturulmuştur.

👨‍💻 Geliştirici

Bircan Yılmaz

About

Entity Framework Core kapsamlı eğitim projesi - Web API, LINQ, async/await, Serilog, Custom Extensions ve EF Core best practices örnekleri içeren modern .NET 8.0 uygulaması

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages