Aicrosoft.DataAccess.EntityFrameworkCore
8.0.0-beta.260130.2
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
<PackageReference Include="Aicrosoft.DataAccess.EntityFrameworkCore" Version="8.0.0-beta.260130.2" />
<PackageVersion Include="Aicrosoft.DataAccess.EntityFrameworkCore" Version="8.0.0-beta.260130.2" />
<PackageReference Include="Aicrosoft.DataAccess.EntityFrameworkCore" />
paket add Aicrosoft.DataAccess.EntityFrameworkCore --version 8.0.0-beta.260130.2
#r "nuget: Aicrosoft.DataAccess.EntityFrameworkCore, 8.0.0-beta.260130.2"
#:package Aicrosoft.DataAccess.EntityFrameworkCore@8.0.0-beta.260130.2
#addin nuget:?package=Aicrosoft.DataAccess.EntityFrameworkCore&version=8.0.0-beta.260130.2&prerelease
#tool nuget:?package=Aicrosoft.DataAccess.EntityFrameworkCore&version=8.0.0-beta.260130.2&prerelease
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
- 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.,
UserRolefor User and Role).
- 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.
- DbContext Implementation:
- Implementation pattern:
class XxxxDbContext(DbContextOptions options) : DbContext(options)
- Implementation pattern:
- Base Entity:
- Entity tables should inherit from
Entity<T>, which defaults a Primary Key namedId. - 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>.
- Entity tables should inherit from
- Indexing:
- (Optional) Index format:
.HasDatabaseName("IX_TableName_ColumnName"). If omitted, EF Core generates this structure automatically.
- (Optional) Index format:
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
DbContextinstances.
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 | Versions 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. |
-
net8.0
- Aicrosoft.DataAccess.Abstractions (>= 8.0.0-beta.260130.2)
- Microsoft.EntityFrameworkCore (>= 8.0.14)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.14)
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 |