Add EF Core packages and create DbContext #59

Closed
opened 2026-01-18 22:29:11 +00:00 by joezombie · 1 comment
joezombie commented 2026-01-18 22:29:11 +00:00 (Migrated from github.com)

Parent Epic

Part of #58 - Migrate to Entity Framework Core

Description

Add Entity Framework Core NuGet packages and create the initial CastrDbContext class.

Packages to Add

<!-- Core EF packages -->
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0" />

<!-- Database providers -->
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0" />

DbContext Implementation

Create Data/CastrDbContext.cs:

public class CastrDbContext : DbContext
{
    public CastrDbContext(DbContextOptions<CastrDbContext> options) 
        : base(options) { }

    public DbSet<Feed> Feeds => Set<Feed>();
    public DbSet<Episode> Episodes => Set<Episode>();
    public DbSet<DownloadedVideo> DownloadedVideos => Set<DownloadedVideo>();
    public DbSet<ActivityLog> ActivityLogs => Set<ActivityLog>();
    public DbSet<DownloadQueueItem> DownloadQueue => Set<DownloadQueueItem>();

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        // Configure relationships, indexes, constraints
        modelBuilder.ApplyConfigurationsFromAssembly(typeof(CastrDbContext).Assembly);
    }
}

File Structure

Castr/
├── Data/
│   ├── CastrDbContext.cs
│   ├── Configurations/
│   │   ├── FeedConfiguration.cs
│   │   ├── EpisodeConfiguration.cs
│   │   ├── DownloadedVideoConfiguration.cs
│   │   ├── ActivityLogConfiguration.cs
│   │   └── DownloadQueueItemConfiguration.cs
│   └── Migrations/
│       └── (EF Core generated migrations)

Tasks

  • Add EF Core packages to Castr.csproj
  • Create Data folder structure
  • Implement CastrDbContext with DbSets
  • Add basic OnModelCreating configuration
  • Register DbContext in Program.cs (temporary SQLite config)
  • Verify project builds successfully

Acceptance Criteria

  • All packages install without conflicts
  • DbContext compiles and can be instantiated
  • EF Core tools work (dotnet ef commands)
## Parent Epic Part of #58 - Migrate to Entity Framework Core ## Description Add Entity Framework Core NuGet packages and create the initial `CastrDbContext` class. ## Packages to Add ```xml <!-- Core EF packages --> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0" /> <!-- Database providers --> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.0" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" /> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0" /> ``` ## DbContext Implementation Create `Data/CastrDbContext.cs`: ```csharp public class CastrDbContext : DbContext { public CastrDbContext(DbContextOptions<CastrDbContext> options) : base(options) { } public DbSet<Feed> Feeds => Set<Feed>(); public DbSet<Episode> Episodes => Set<Episode>(); public DbSet<DownloadedVideo> DownloadedVideos => Set<DownloadedVideo>(); public DbSet<ActivityLog> ActivityLogs => Set<ActivityLog>(); public DbSet<DownloadQueueItem> DownloadQueue => Set<DownloadQueueItem>(); protected override void OnModelCreating(ModelBuilder modelBuilder) { // Configure relationships, indexes, constraints modelBuilder.ApplyConfigurationsFromAssembly(typeof(CastrDbContext).Assembly); } } ``` ## File Structure ``` Castr/ ├── Data/ │ ├── CastrDbContext.cs │ ├── Configurations/ │ │ ├── FeedConfiguration.cs │ │ ├── EpisodeConfiguration.cs │ │ ├── DownloadedVideoConfiguration.cs │ │ ├── ActivityLogConfiguration.cs │ │ └── DownloadQueueItemConfiguration.cs │ └── Migrations/ │ └── (EF Core generated migrations) ``` ## Tasks - [ ] Add EF Core packages to Castr.csproj - [ ] Create Data folder structure - [ ] Implement CastrDbContext with DbSets - [ ] Add basic OnModelCreating configuration - [ ] Register DbContext in Program.cs (temporary SQLite config) - [ ] Verify project builds successfully ## Acceptance Criteria - [ ] All packages install without conflicts - [ ] DbContext compiles and can be instantiated - [ ] EF Core tools work (`dotnet ef` commands)
joezombie commented 2026-01-26 22:25:24 +00:00 (Migrated from github.com)

Completed: Added EF Core packages (Microsoft.EntityFrameworkCore, providers for SQLite, PostgreSQL, SQL Server, MySQL) and created CastrDbContext with entity configurations.

Completed: Added EF Core packages (Microsoft.EntityFrameworkCore, providers for SQLite, PostgreSQL, SQL Server, MySQL) and created CastrDbContext with entity configurations.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
joezombie/castr#59
No description provided.