Aicrosoft.DataAccess.EntityFrameworkCore 8.0.0-beta.260130.2

This is a prerelease version of Aicrosoft.DataAccess.EntityFrameworkCore.
dotnet add package Aicrosoft.DataAccess.EntityFrameworkCore --version 8.0.0-beta.260130.2
                    
NuGet\Install-Package Aicrosoft.DataAccess.EntityFrameworkCore -Version 8.0.0-beta.260130.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Aicrosoft.DataAccess.EntityFrameworkCore" Version="8.0.0-beta.260130.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Aicrosoft.DataAccess.EntityFrameworkCore" Version="8.0.0-beta.260130.2" />
                    
Directory.Packages.props
<PackageReference Include="Aicrosoft.DataAccess.EntityFrameworkCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Aicrosoft.DataAccess.EntityFrameworkCore --version 8.0.0-beta.260130.2
                    
#r "nuget: Aicrosoft.DataAccess.EntityFrameworkCore, 8.0.0-beta.260130.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Aicrosoft.DataAccess.EntityFrameworkCore@8.0.0-beta.260130.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Aicrosoft.DataAccess.EntityFrameworkCore&version=8.0.0-beta.260130.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Aicrosoft.DataAccess.EntityFrameworkCore&version=8.0.0-beta.260130.2&prerelease
                    
Install as a Cake Tool

Aicrosoft.DataAccess.EntityFrameworkCore

Aicrosoft.DataAccess.EntityFrameworkCore references Aicrosoft.DataAccess, enabling direct access to IRepository<Entity, Pkey> instances implemented in this library via IOC to operate on relevant databases.

Design Goals & Entity Guidelines

  1. Simplified Relationships:
    • Generally, do not design FK (Foreign Key) constraints in the database. Constraint relationships should be handled by the application logic. Database-level constraints are reserved for special table structures.
    • Entities should be cohesive. If a relationship exists with another table, it is best to introduce a dedicated relationship table (e.g., UserRole for User and Role).
  2. Simple Entities:
    • Complex entities (nested references to other table entities or collections) raise the bar for developers and are prone to issues. Keep table relationships simple and rely on business logic to maintain data integrity.
  3. DbContext Implementation:
    • Implementation pattern: class XxxxDbContext(DbContextOptions options) : DbContext(options)
  4. Base Entity:
    • Entity tables should inherit from Entity<T>, which defaults a Primary Key named Id.
    • Default values should ideally be set in the property/constructor, as different DBs handle default value generation differently.
    • Entities with custom or composite keys do not need to inherit from Entity<T>.
  5. Indexing:
    • (Optional) Index format: .HasDatabaseName("IX_TableName_ColumnName"). If omitted, EF Core generates this structure automatically.

Key Interfaces

IRepository<TEntity, TKey>

Primary interface for storage operations on a specific entity within a DbContext.

  • TEntity: The entity type.
  • TKey: The type of the entity's primary key.

ICommonRepository

Interface for database-related operations that are agnostic to specific entities (e.g., execution of raw SQL, transaction management).

Note: Connection count is directly related to the number of DbContext instances.

How To Use

1. Define Entities

Inherit from Entity<TKey> for standard tables.

public class Phone : Entity<Guid>
{
    public string? PhoneNumber { get; set; }
}

public class Employe : Entity<int>
{
    public string? Name { get; set; }
    // Avoid complex navigation properties if adhering to the "Simple Entities" design goal
    // public List<Phone>? Phones { get; set; } 
}

2. Create DbContext

Initialize DbContext with DbContextOptions.

public class SqlServerSampleDbContext : DbContext
{
    // Constructor allows passing connection string via options
    public SqlServerSampleDbContext(DbContextOptions options) : base(options) { }

    public DbSet<Employe>? Employes { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        // Connection string is configured via Dependency Injection (AddDbContext)
    }
}

3. Migrations (dotnet-ef)

Ensure Microsoft.EntityFrameworkCore.Design is installed in the project containing the DbContext.

# Install EF Core tools
dotnet tool install --global dotnet-ef

# Add a migration
dotnet ef migrations add init --context SqlServerSampleDbContext

# Update database
dotnet ef database update --context SqlServerSampleDbContext

4. Usage via Dependency Injection

Inject IRepository<TEntity, TKey> to perform CRUD operations.

public class MyService
{
    private readonly IRepository<Employe, int> _empRepo;

    public MyService(IRepository<Employe, int> empRepo)
    {
        _empRepo = empRepo;
    }

    public async Task AddEmployee()
    {
        await _empRepo.AddAsync(new Employe { Name = "Test User" });
        await _empRepo.SaveChangesAsync();
    }
}
Product 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 was computed.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Aicrosoft.DataAccess.EntityFrameworkCore:

Package Downloads
Aicrosoft.DataAccess.DbMigration

Extensions of Aicrosoft Ltd.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.0.0-beta.260130.2 0 1/30/2026
8.0.0-beta.260127.1 33 1/27/2026
8.0.0-beta.251110.1 192 11/10/2025