📚 IrbyImaging.DbContext Project Documentation
📑 Table of Contents
- Overview & Purpose
- Project Structure
- Target Framework
- Key Functional Areas
- Dependencies & Technologies
- DomainClasses Reference
- Setup & Usage
- Sample Code Blocks
- UML Diagram
- Conclusion
1. Overview & Purpose
IrbyImaging.DbContext is a .NET 9.0 class‐library project responsible for configuring and exposing the Entity Framework Core DbContext for the IrbyImaging solution. It serves as the data‐access layer, mapping your domain entities (in IrbyImaging.DomainClasses) to relational database tables, managing migrations, seeding data, and integrating with third‐party stores (Azure, SQL Server, etc.).
🎯 Goals:
- Provide a strongly‐typed EF Core context for all imaging‐related entities
- Integrate with Azure Key Vault, Blob Storage, and Always Encrypted
- Support migrations, in‐memory testing, and SQL Server production
- Leverage a rich ecosystem of PDF, Excel, reporting, and automation libraries
2. Project Structure
IrbyImaging.DbContext/
├─ IrbyImaging.DbContext.csproj ← Project file (this document)
└─ (sources typically include:)
├─ ImagingDbContext.cs ← EF Core DbContext implementation
├─ Configuration/ ← Fluent‐API configurations
├─ Migrations/ ← EF Core migration files
└─ Utilities/ ← Helpers (Key Vault, Blob helpers, etc.)
Note: Only the
.csprojis shown here. Actual source files (DbContext, Entities, Configs) live alongside in this folder.
3. Target Framework
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>
- net9.0: Leverages the latest .NET improvements—performance, C# 12 features, minimal APIs, and more.
- Compatible with cross-platform deployment and modern Azure services.
4. Key Functional Areas
-
Entity Framework Core
- Core DbContext (
ImagingDbContext) - Migrations & Tools
- In‐Memory provider for testing
- Core DbContext (
-
Azure Integration
- Key Vault secrets (
Azure.Extensions.AspNetCore.Configuration.Secrets) - Blob Storage for binary assets
- Key Vault secrets (
-
Reporting & Document Processing
- Bold Reports
- Syncfusion (PDF, Excel, Word, Charting, Pivot)
- IronOCR, IronPDF, iTextSharp
-
Security & Authentication
- Azure AD / OpenID Connect
- ASP.NET Core Identity
-
Automation & Scheduling
- Selenium WebDriver
- Quartz.NET
-
Utilities & Code Analysis
- CsvHelper, ClosedXML, IronWebScraper
- Roslyn analyzers
5. Dependencies & Technologies
| Category | Packages (selection) | Purpose |
|---|---|---|
| ORM & Data | Microsoft.EntityFrameworkCore (9.0.0)Microsoft.EntityFrameworkCore.SqlServer (9.0.0)Microsoft.EntityFrameworkCore.InMemory (9.0.0)Microsoft.EntityFrameworkCore.Tools | Core ORM, SQL Server provider, In‐Memory for testing, migrations |
| Azure | Azure.Extensions.AspNetCore.Configuration.Secrets (1.3.2)Azure.Security.KeyVault.Secrets (4.7.0)Azure.Storage.Blobs (12.23.0)Microsoft.Extensions.Azure (1.9.0) | Key Vault, Blob Storage, Azure dependency injection |
| Security & Identity | Microsoft.AspNetCore.Authentication.OpenIdConnect (9.0.0)Microsoft.AspNetCore.Identity.EntityFrameworkCore (9.0.0)Microsoft.Identity.Web (3.5.0) | OpenID Connect, ASP.NET Identity, Azure AD integration |
| Reporting & PDF | BoldReports.AspNet.Core (6.3.18)BoldReports.Net.Core (6.3.18)Syncfusion.Pdf.Net.Core (28.1.33)iTextSharp (5.5.13.4)IronPdf (2024.12.9) | In‐app reporting, PDF creation & manipulation |
| Excel & CSV | ClosedXML (0.104.2)CsvHelper (33.0.1)IronXL.Excel (2025.2.5)Syncfusion.XlsIO.Net.Core (28.1.33) | Excel reading/writing, CSV parsing |
| OCR & Scraping | IronOcr (2024.12.2)IronWebScraper (2024.12.1) | Optical character recognition, web scraping |
| Code Analysis | Microsoft.CodeAnalysis.* (4.x)Microsoft.CodeAnalysis.Analyzers (3.11.0) | Roslyn compiler APIs and analyzers |
| SQL Management | Microsoft.SqlServer.SqlManagementObjects (172.52.0)System.Data.SqlClient (4.9.0) | Programmatic SQL Server management |
| Automation & Scheduling | Quartz (3.13.1)Selenium.WebDriver (4.27.0)Selenium.WebDriver.ChromeDriver (131.0.6778.20400) | Job scheduling, browser automation |
| Mail & Office | NETCore.MailKit (2.1.0)MimeKit (4.9.0)Microsoft.Office.Interop.Outlook (15.0.4797.1004) | SMTP/email, Outlook automation |
| Testing | Microsoft.NET.Test.Sdk (17.12.0)xunit.runner.visualstudio (2.8.2)coverlet.collector (6.0.2) | Test runner, coverage |
| Syncfusion | Syncfusion.EJ2.AspNet.Core (28.1.33)Syncfusion.Licensing (28.1.33) plus various Syncfusion components | Rich UI components, file export |
💡 Each reference in the
.csprojis automatically resolved via NuGet. PrivateAssets/IncludeAssets flags isolate analyzers & test SDKs.
6. DomainClasses Reference
<ItemGroup>
<ProjectReference Include="..\IrbyImaging.DomainClasses\IrbyImaging.DomainClasses.csproj" />
</ItemGroup>
- IrbyImaging.DomainClasses: Contains your POCO entity definitions (e.g.,
Patient,ImagingStudy,Report) - This project‐to‐project reference lets ImagingDbContext access the
DbSet<TEntity>properties and configure the EF model.
7. Setup & Usage
-
Restore & Build
dotnet restore ./IrbyImaging.DbContext/IrbyImaging.DbContext.csproj dotnet build ./IrbyImaging.DbContext/IrbyImaging.DbContext.csproj -
Configure Connection String
In your host app (e.g., WebAPI), add inappsettings.json:{ "ConnectionStrings": { "Default": "Server=.;Database=IrbyImaging;Trusted_Connection=True;" } } -
Register DbContext
// In Program.cs / Startup.cs builder.Services.AddDbContext<ImagingDbContext>(options => options.UseSqlServer(configuration.GetConnectionString("Default"))); -
Add & Apply Migrations
cd IrbyImaging.DbContext dotnet ef migrations add InitialCreate dotnet ef database update -
Azure Key Vault (Optional)
builder.Configuration .AddAzureKeyVault(new Uri(keyVaultUri), new DefaultAzureCredential());
8. Sample Code Blocks
csproj Snippet
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<!-- Entity Framework Core -->
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<!-- Azure Key Vault -->
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.7.0" />
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.3.2" />
<!-- Reporting -->
<PackageReference Include="BoldReports.AspNet.Core" Version="6.3.18" />
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="28.1.33" />
<!-- Many more... -->
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\IrbyImaging.DomainClasses\IrbyImaging.DomainClasses.csproj" />
</ItemGroup>
</Project>
Registering the DbContext
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ImagingDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("Default")));
// ... other services
}
}
9. UML Diagram
classDiagram
class ImagingDbContext {
+DbSet<Patient> Patients
+DbSet<ImagingStudy> Studies
+OnModelCreating(ModelBuilder)
}
class DomainClasses {
<<Package>>
Patient
ImagingStudy
Report
}
class AzureKeyVaultProvider
class BlobStorageHelper
DomainClasses --> ImagingDbContext : entities
ImagingDbContext --> AzureKeyVaultProvider : secures keys
ImagingDbContext --> BlobStorageHelper : stores assets
📊 This high‐level class diagram shows how
ImagingDbContextties together domain entities, Azure Key Vault, and Blob Storage.
10. Conclusion
IrbyImaging.DbContext is the backbone of your data layer—providing EF Core linkage, robust third‐party integrations (Azure, Syncfusion, BoldReports, IronOCR, Selenium, Quartz, etc.), and a testable, modular setup. By centralizing all your package references and the ImagingDbContext logic in this project, you maintain a clear separation of concerns:
- DomainClasses: Pure POCOs
- DbContext: Mapping, migrations, storage integration
- Host App: APIs, UI, workflows
🚀 Next Steps:
- Extend
ImagingDbContextwith newDbSet<TEntity>as your domain grows - Add Fluent‐API configurations under the
Configuration/folder - Automate migrations in CI/CD pipelines
- Leverage the rich reporting & PDF libraries for dynamic document generation
Thank you for using IrbyImaging.DbContext!
Feel free to file issues or contribute improvements on the Git repository.
Happy coding! 👩💻👨💻