Automates EF Core workflows including migrations, entity modifications, and model seeding.

Install

mkdir -p .claude/skills/ef-skill && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/17956" && unzip -o skill.zip -d .claude/skills/ef-skill && rm skill.zip

Installs to .claude/skills/ef-skill

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Entity Framework (EF) Core operations - add/modify entities, run migrations, seed data
86 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Add new tables or entities to the database
  • Modify existing tables by adding new fields
  • Run Entity Framework Core migrations
  • Update the database schema
  • Configure relationships between tables

How it works

This skill provides guidance and commands for managing Entity Framework Core operations, including adding/modifying entities, running migrations, seeding data, and configuring relationships within a DbContext.

Inputs & outputs

You give it
Changes to C# model classes or DbContext configuration
You get back
Generated EF Core migrations, an updated database schema, or configured entity relationships

When to use ef-skill

  • Adding new entities to a database
  • Updating existing schema fields
  • Running dotnet ef migration commands
  • Configuring one-to-many or many-to-many relationships

About this skill

Entity Framework (EF) Core Skill - Lab 3

Ovaj skill pružava smjernice za rad s Entity Framework Core u Lab 3 projektu.

Kada koristiti ovaj skill

  • Trebate dodati novu tablicu/entitet u bazu podataka
  • Trebate promijeniti postojeću tablicu (npr. dodati novo polje)
  • Trebate pokrenuti migraciju
  • Trebate ažurirati bazu podataka
  • Trebate dodati novu relaciju između tablica

Važne naredbe

1. Pokretanje migracija (uvijek iz lab-3 direktorija)

cd c:\Users\Mihael\Desktop\ASP.NET\lab-3

# Kreiraj novu migraciju s opisnim nazivom
dotnet ef migrations add AddNewFeature

# Primjeni migraciju na bazu
dotnet ef database update

# Prikaži listu svih migracija
dotnet ef migrations list

2. Uključivanje podataka pri konfiguraciji (DbContext.OnModelCreating)

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    base.OnModelCreating(modelBuilder);

    // Seeding podataka
    modelBuilder.Entity<Author>().HasData(
        new Author { Id = 1, FirstName = "Stephen", LastName = "King", ... }
    );
}

3. Konfiguracija relationship-a

// 1-N veza (jedan autor, mnogu knjiga)
modelBuilder.Entity<Book>()
    .HasOne(b => b.Author)
    .WithMany(a => a.Books)
    .HasForeignKey(b => b.AuthorId);

// N-N veza (mnogo knjiga, mnogo žanrova)
modelBuilder.Entity<BookGenre>()
    .HasKey(bg => new { bg.BookId, bg.GenreId });

Korak-po-korak: Dodavanje novog entiteta

Korak 1: Kreiraj modelsku klasu

// Models/Award.cs
using System.ComponentModel.DataAnnotations;

namespace Lab3.Models;

public class Award
{
    [Key]
    public int Id { get; set; }

    public string Name { get; set; } = string.Empty;

    public string Description { get; set; } = string.Empty;

    public DateTime AwardedOn { get; set; }

    // Foreign key
    [ForeignKey(nameof(Book))]
    public int BookId { get; set; }

    public virtual Book Book { get; set; } = default!;
}

Korak 2: Dodaj DbSet u DbContext

// Data/CatalogDbContext.cs
public DbSet<Award> Awards { get; set; }

Korak 3: Ažuriraj model relationships (ako je potrebno)

// Models/Book.cs
public virtual ICollection<Award> Awards { get; set; } = new List<Award>();

Korak 4: Konfiguriraj relationships u DbContext.OnModelCreating

modelBuilder.Entity<Award>()
    .HasOne(a => a.Book)
    .WithMany(b => b.Awards)
    .HasForeignKey(a => a.BookId)
    .OnDelete(DeleteBehavior.Cascade);

Korak 5: Kreiraj migraciju

dotnet ef migrations add AddAwardEntity

Korak 6: Primjeni migraciju

dotnet ef database update

Korak-po-korak: Dodavanje novog polja na postojeći entitet

Korak 1: Dodaj svojstvo u modelsku klasu

// Models/Book.cs
public class Book
{
    // ...
    public string Genre { get; set; } = string.Empty;  // Novo polje
}

Korak 2: Kreiraj migraciju (EF će automatski detektirati promjenu)

dotnet ef migrations add AddGenreFieldToBook

Korak 3: Pregledaj migracijsku datoteku

# Migracija će biti u Migrations/ foldera
# Trebao bi viditi AddColumn komandu za novo polje

Korak 4: Primjeni migraciju

dotnet ef database update

Često postavljana pitanja (FAQ)

P: Kako resetiram bazu?

# Obriši bazu datoteke
Remove-Item catalog.db

# Primjeni sve migracije ispočetka
dotnet ef database update

P: Kako vidim SQL skripte koje EF generira?

# Izvezi migracije kao SQL script
dotnet ef migrations script

P: Što ako migracija ne uspije primjenjivanja na bazu?

# Ukloni zadnju migraciju (ako je neuspješna)
dotnet ef migrations remove

# Ili resetiraj bazu i kreni ispočetka
Remove-Item catalog.db
dotnet ef database update

Best Practices

Koristite async-await pri pozivu baze u kontrolerima ✓ Koristi Include() pri učitavanju povezanih entiteta

var book = await _context.Books
    .Include(b => b.Author)
    .Include(b => b.Reviews)
    .FirstOrDefaultAsync(b => b.Id == id);

Izbjegavaj N+1 problema s Include i ThenInclude ✓ Koristi virtual svojstva za lazy loading relacija ✓ Postavi DeleteBehavior na Cascade za važne veze

.OnDelete(DeleteBehavior.Cascade);

Provjerit migracije prije commitiranja

dotnet ef migrations list

Datoteke važne za EF

DatotekaUloga
Data/CatalogDbContext.csDbContext - veza s bazom
Models/*.csModelske klase - reprezentacija tablica
Migrations/Migracijske skripte
appsettings.jsonConnection string

SQL Lite specifičnosti

  • Podržava foreignke keys s PRAGMA foreign_keys = ON
  • Ne podržava sve SQL tipove kao MSSQL
  • Optimalna za development i male projekte

Primjer kompletan workflow

cd c:\Users\Mihael\Desktop\ASP.NET\lab-3

# 1. Promijeni model (npr. dodaj novo polje)
# 2. Kreiraj migraciju
dotnet ef migrations add DescriptiveChangeName

# 3. Pregledaj datoteku Migrations/XXX_DescriptiveChangeName.cs
# (Opciono) Uređuj ako EF nije detektirao sve ispravno

# 4. Primjeni promjene na bazu
dotnet ef database update

# 5. Testiraj aplikaciju
dotnet run

Verzija: 1.0
Zadnja ažurenja: 2026-05-07
Autor: GitHub Copilot

When not to use it

  • When working with database technologies other than Entity Framework Core
  • When the project is not Lab 3
  • When only SQL scripts are needed without EF Core migration management

Limitations

  • Specific to Entity Framework Core
  • Commands are tailored for a Windows PowerShell environment
  • Requires manual review of generated migration files

How it compares

This skill offers a structured, command-line driven approach to managing database schema and data with Entity Framework Core, providing specific commands and step-by-step procedures that differ from manual SQL scripting.

Compared to similar skills

ef-skill side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
ef-skill (this skill)02moNo flagsIntermediate
efcore-migrations03moNo flagsIntermediate
azure-resource-manager-mysql-dotnet12moReviewIntermediate
azure-resource-manager-postgresql-dotnet12moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

efcore-migrations

thecaaz

**WORKFLOW SKILL** — EF Core migrations workflow for backend model changes: generate, review, and apply EF Core migrations using the repository's README guidance. Agents MUST NOT hand-edit migration code — migrations must be generated with the `dotnet ef migrations add` tool.

00

azure-resource-manager-mysql-dotnet

microsoft

Azure MySQL Flexible Server SDK for .NET. Database management for MySQL Flexible Server deployments. Use for creating servers, databases, firewall rules, configurations, backups, and high availability. Triggers: "MySQL", "MySqlFlexibleServer", "MySQL Flexible Server", "Azure Database for MySQL", "MySQL database management", "MySQL firewall", "MySQL backup".

14

azure-resource-manager-postgresql-dotnet

microsoft

Azure PostgreSQL Flexible Server SDK for .NET. Database management for PostgreSQL Flexible Server deployments. Use for creating servers, databases, firewall rules, configurations, backups, and high availability. Triggers: "PostgreSQL", "PostgreSqlFlexibleServer", "PostgreSQL Flexible Server", "Azure Database for PostgreSQL", "PostgreSQL database management", "PostgreSQL firewall", "PostgreSQL backup", "Postgres".

13

azure-resource-manager-sql-dotnet

microsoft

Azure Resource Manager SDK for Azure SQL in .NET. Use for MANAGEMENT PLANE operations: creating/managing SQL servers, databases, elastic pools, firewall rules, and failover groups via Azure Resource Manager. NOT for data plane operations (executing queries) - use Microsoft.Data.SqlClient for that. Triggers: "SQL server", "create SQL database", "manage SQL resources", "ARM SQL", "SqlServerResource", "provision Azure SQL", "elastic pool", "firewall rule".

13

appsettings

punk-link

Rules for modifying ASP.NET Core configuration files (appsettings*.json) in the Warp project. Use when: adding, removing, or changing any configuration key in appsettings files; creating new Options classes that bind to configuration; the user mentions 'appsettings', 'configuration', 'options', 'con

00

efcore-patterns

pdldynamicsltd

Entity Framework Core patterns for ASP.NET Zero (DbContext, repositories, migrations)

00

Search skills

Search the agent skills registry