Sufficit.EFData
1.26.909.1815
dotnet add package Sufficit.EFData --version 1.26.909.1815
NuGet\Install-Package Sufficit.EFData -Version 1.26.909.1815
<PackageReference Include="Sufficit.EFData" Version="1.26.909.1815" />
<PackageVersion Include="Sufficit.EFData" Version="1.26.909.1815" />
<PackageReference Include="Sufficit.EFData" />
paket add Sufficit.EFData --version 1.26.909.1815
#r "nuget: Sufficit.EFData, 1.26.909.1815"
#:package Sufficit.EFData@1.26.909.1815
#addin nuget:?package=Sufficit.EFData&version=1.26.909.1815
#tool nuget:?package=Sufficit.EFData&version=1.26.909.1815
<h1> Sufficit.EFData <a href="https://github.com/sufficit"><img src="https://avatars.githubusercontent.com/u/66928451?s=200&v=4" alt="Sufficit Logo" width="80" align="right"></a> </h1>
Worktrees (padrão Sufficit): toda árvore de trabalho deste projeto (humanos ou agentes de IA) deve ser criada dentro da pasta do próprio projeto:
git worktree add .worktrees/<nome>. A pasta.worktrees/é ignorada pelo git (.gitignore→**/.worktrees/) e nunca deve ser versionada ou criada fora da raiz do repositório.
Entity Framework Data Providers for Sufficit Ecosystem
A comprehensive .NET library that provides Entity Framework-based data access providers for the Sufficit platform. This library implements the Provider Architecture Pattern with extension methods for optimal performance and maintainability.
📋 Table of Contents
- About
- Features
- Architecture
- Installation
- Usage
- Modules
- Configuration
- Database migrations
- Development
- Contributing
- License
📖 About
Sufficit.EFData is a core component of the Sufficit ecosystem, providing standardized data access patterns using Entity Framework Core. The library implements a consistent provider architecture that ensures:
- Multi-target Framework Support: Compatible with .NET 7, .NET 9, and .NET 10
- Provider Pattern: Clean separation between data access logic and business logic
- Extension Methods: Convenient query methods without additional abstraction layers
- Dependency Injection: Seamless integration with Microsoft.Extensions.DependencyInjection
- Database Agnostic: Support for multiple database providers (MySQL, SQL Server, etc.)
Key Principles
- Single Responsibility: Each provider handles one specific domain
- Extension Methods: Business logic extensions without repository overhead
- Scoped Contexts: Proper DbContext lifecycle management
- Consistent API: Uniform interface across all providers
✨ Features
🔧 Core Features
- Multi-Framework Targeting: Supports .NET 7, .NET 9, and .NET 10
- Provider Architecture: Clean separation of data access concerns
- Extension Methods: Fluent API for complex queries
- Dependency Injection: Native support for IServiceCollection
- Database Providers: MySQL, SQL Server, and PostgreSQL support
- Migration Tools: Built-in database migration utilities
📊 Domain Modules
- Exchange: Email tracking, message templates, and communication logs
- Identity: User management and authentication data
- Contacts: Customer and contact information management
- Telephony: Call records, CDR data, and telephony operations
- Finance: Billing, payments, and financial transactions
- Statistics: Analytics and reporting data
- Storage: File and media storage management
- Tasks: Background job and task management
🛠️ Developer Experience
- IntelliSense Support: Full IDE integration
- Comprehensive Documentation: Detailed API documentation
- Code Examples: Practical usage samples
- Migration Tools: Database schema management
- Testing Support: Unit testing utilities
🏗️ Architecture
Provider Pattern Implementation
Sufficit.EFData/
├── EFProvider<TContext> # Abstract base provider
├── ScopedProvider # Scoped service management
├── Extension Methods # Query extensions
└── DbContext Implementations # Database contexts
Key Components
EFProvider Base Class
public abstract class EFProvider<DBContext> : ScopedProvider
where DBContext : Microsoft.EntityFrameworkCore.DbContext
{
protected EFProvider(IServiceScopeFactory serviceScopeFactory)
: base(serviceScopeFactory) { }
protected DBContext CreateDbContext(IServiceScope scope)
=> scope.ServiceProvider.GetRequiredService<DBContext>();
}
Extension Methods Pattern
public static class EFMessageTemplateProviderExtensions
{
public static async Task<MessageTemplate?> GetByTitleAsync(
this EFMessageTemplateProvider provider,
string title,
CancellationToken cancellationToken = default)
{
return await provider.Search(new MessageTemplateSearchParameters
{
Title = title
}).FirstOrDefaultAsync(cancellationToken);
}
}
Database Context Management
- Scoped Lifetime: DbContext instances are properly scoped
- Connection Pooling: Efficient database connection management
- Transaction Support: ACID transaction handling
- Migration Support: Automatic schema updates
📦 Installation
NuGet Package
# Install via NuGet
dotnet add package Sufficit.EFData
# Or via Package Manager
Install-Package Sufficit.EFData
Package Reference
<PackageReference Include="Sufficit.EFData" Version="1.0.0" />
Prerequisites
- .NET 7, .NET 9, or .NET 10
- Entity Framework Core packages
- Database Provider (MySQL, SQL Server, etc.)
The legacy netstandard2.0 target was retired because its EF Core 3.1 MySQL
provider required Newtonsoft.Json. Sufficit.EFData standardizes JSON handling
on System.Text.Json and rejects Newtonsoft dependencies during build and test.
🚀 Usage
Basic Setup
// Program.cs or Startup.cs
using Microsoft.Extensions.DependencyInjection;
using Sufficit.EFData;
public void ConfigureServices(IServiceCollection services)
{
// Add database context
services.AddDbContext<ExchangeDbContext>(options =>
options.UseMySql(connectionString,
new MySqlServerVersion(new Version(8, 0, 21))));
// Register providers
services.AddSufficitEFData();
}
Using Providers
public class MessageService
{
private readonly EFMessageTemplateProvider _provider;
public MessageService(EFMessageTemplateProvider provider)
{
_provider = provider;
}
public async Task<MessageTemplate?> GetTemplateAsync(string title)
{
// Using extension method
return await _provider.GetByTitleAsync(title);
}
public async Task<IEnumerable<MessageTemplate>> SearchTemplatesAsync(
string? searchTerm = null,
int page = 1,
int pageSize = 20)
{
// Using base Search method
return await _provider.Search(new MessageTemplateSearchParameters
{
Title = searchTerm,
Paging = new PagingParameters { Page = page, PageSize = pageSize }
}).ToListAsync();
}
}
Advanced Queries
public async Task<IEnumerable<MessageTemplate>> GetActiveTemplatesAsync()
{
return await _provider.Search(new MessageTemplateSearchParameters
{
IsActive = true,
Sorting = new SortingParameters
{
SortBy = "CreatedAt",
SortDirection = SortDirection.Descending
}
}).ToListAsync();
}
📚 Modules
Exchange Module
Handles email templates, message tracking, and communication logs.
// Usage
public class EmailService
{
private readonly EFMessageTemplateProvider _templateProvider;
private readonly EFEMailTrackingProvider _trackingProvider;
public async Task SendTemplatedEmailAsync(string templateTitle, string recipient)
{
var template = await _templateProvider.GetByTitleAsync(templateTitle);
if (template == null) return;
// Send email logic here
await _trackingProvider.TrackEmailAsync(template.Id, recipient);
}
}
Identity Module
Manages user authentication and authorization data.
// Register Identity providers
services.AddSufficitIdentityProviders();
// Usage
public class UserService
{
private readonly EFIdentityProvider _identityProvider;
public async Task<User?> AuthenticateAsync(string username, string password)
{
return await _identityProvider.AuthenticateAsync(username, password);
}
}
Telephony Module
Handles call records, CDR data, and telephony operations.
// Register Telephony providers
services.AddSufficitTelephonyProviders();
// Usage
public class CallService
{
private readonly EFCallRecordProvider _callProvider;
public async Task<IEnumerable<CallRecord>> GetRecentCallsAsync(string extension)
{
return await _callProvider.Search(new CallRecordSearchParameters
{
Extension = extension,
DateRange = new DateTimeRange
{
Start = DateTime.UtcNow.AddDays(-7),
End = DateTime.UtcNow
}
}).ToListAsync();
}
}
⚙️ Configuration
Connection Strings
{
"ConnectionStrings": {
"ExchangeDb": "Server=localhost;Database=exchange;User=user;Password=password;",
"IdentityDb": "Server=localhost;Database=identity;User=user;Password=password;",
"TelephonyDb": "Server=localhost;Database=telephony;User=user;Password=password;"
}
}
Service Registration
public void ConfigureServices(IServiceCollection services)
{
// Database contexts
services.AddDbContext<ExchangeDbContext>(options =>
options.UseMySql(Configuration.GetConnectionString("ExchangeDb"),
new MySqlServerVersion(new Version(8, 0, 21))));
services.AddDbContext<IdentityDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("IdentityDb")));
// Providers
services.AddSufficitEFData();
}
🗄️ Database migrations
All database migrations are maintained in the dedicated migrations project. Runtime code under src/ contains contexts, mappings and providers; do not add versioned SQL scripts or generated migration classes there. An architectural unit test rejects migration artifacts placed anywhere outside the dedicated project.
migrations/src/<Domain>/: Entity Framework factories, migration classes and model snapshots usingSufficit.EFData.<Domain>.Migrations.migrations/sql/<Domain>/: reviewed, versioned SQL migrations and data seeds, optionally grouped by subdomain.migrations/docs/<Domain>/: migration-specific decisions, preconditions and validation records.
Use a sortable yyyyMMddHHmm-description prefix for SQL and documentation artifacts. Prefer additive and idempotent scripts, state the target schema explicitly, validate with a transaction/rollback when possible, and never commit credentials. Schema changes must be applied deliberately through the migrations host or an explicitly reviewed SQL artifact—not automatically from application startup.
See migrations/README.md for the workflow and commands.
💻 Development
Project Structure
Sufficit.EFData/
├── src/
│ ├── EFProvider.cs # Base provider class
│ ├── ScopedProvider.cs # Scoped service management
│ ├── DEFAULT.cs # Constants and utilities
│ ├── Exchange/ # Exchange domain providers
│ ├── Identity/ # Identity domain providers
│ ├── Telephony/ # Telephony domain providers
│ ├── Contacts/ # Contacts domain providers
│ ├── Finance/ # Finance domain providers
│ └── Extensions/ # Extension methods
├── tests/ # Unit tests
├── docs/ # Documentation
└── migrations/ # Dedicated migration host and artifacts
├── Sufficit.EFData.Migrations.csproj
├── src/ # EF migrations grouped by domain/namespace
│ ├── Finance/
│ ├── Telephony/
│ └── Gateway/WhatsApp/
├── sql/ # SQL grouped by domain and subdomain
│ ├── Finance/
│ ├── Sales/
│ └── Telephony/
└── docs/ # Documentation grouped by domain
Building the Project
# Restore dependencies
dotnet restore
# Build for all target frameworks
dotnet build --configuration Release
# Run tests
dotnet test
# Create NuGet package
dotnet pack --configuration Release
Testing
// Example unit test
[Fact]
public async Task GetByTitleAsync_ReturnsCorrectTemplate()
{
// Arrange
var options = new DbContextOptionsBuilder<ExchangeDbContext>()
.UseInMemoryDatabase(databaseName: "TestDb")
.Options;
using var context = new ExchangeDbContext(options);
var provider = new EFMessageTemplateProvider(context);
// Act
var result = await provider.GetByTitleAsync("Welcome Email");
// Assert
Assert.NotNull(result);
Assert.Equal("Welcome Email", result.Title);
}
🤝 Contributing
We welcome contributions! Please follow these guidelines:
Development Setup
Fork the repository
Clone your fork
git clone https://github.com/yourusername/sufficit-efdata.git cd sufficit-efdataCreate a feature branch
git checkout -b feature/new-providerMake your changes
Add tests for new functionality
Ensure all tests pass
dotnet testSubmit a pull request
Code Standards
- Follow C# coding conventions
- Use meaningful variable and method names
- Add XML documentation comments
- Write unit tests for new features
- Ensure code coverage > 80%
Commit Messages
Use conventional commit format:
feat: add new email tracking provider
fix: resolve connection timeout issue
docs: update API documentation
test: add unit tests for message templates
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
Developed by Sufficit Soluções em Tecnologia da Informação
For more information, visit our GitHub repository or contact development@sufficit.com.br.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 is compatible. 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. |
-
net10.0
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.12 && < 11.0.0)
- Microsoft.Data.SqlClient (>= 6.1.6)
- Microsoft.EntityFrameworkCore (>= 10.0.12 && < 11.0.0)
- Microsoft.EntityFrameworkCore.SqlServer (>= 10.0.12 && < 11.0.0)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.12 && < 11.0.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.12 && < 11.0.0)
- Microsoft.Extensions.Configuration (>= 10.0.12 && < 11.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.12 && < 11.0.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.12 && < 11.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.12 && < 11.0.0)
- Microsoft.Extensions.Identity.Stores (>= 10.0.12 && < 11.0.0)
- Microsoft.Extensions.Logging (>= 10.0.12 && < 11.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.12 && < 11.0.0)
- Microsoft.Extensions.Logging.Configuration (>= 10.0.12 && < 11.0.0)
- Microsoft.Extensions.Options (>= 10.0.12 && < 11.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.12 && < 11.0.0)
- Microsoft.Extensions.Primitives (>= 10.0.12 && < 11.0.0)
- Pomelo.EntityFrameworkCore.MySql (>= 10.0.0)
- Sufficit.Asterisk.Utils (>= 1.26.906.1626)
- Sufficit.Base (>= 1.26.909.1726)
- Sufficit.Json (>= 1.26.906.1634)
- Sufficit.Utils (>= 1.26.909.1727)
-
net7.0
- Microsoft.Bcl.AsyncInterfaces (>= 8.0.0 && < 9.0.0)
- Microsoft.Data.SqlClient (>= 5.2.3)
- Microsoft.EntityFrameworkCore (>= 7.0.20 && < 8.0.0)
- Microsoft.EntityFrameworkCore.SqlServer (>= 7.0.20 && < 8.0.0)
- Microsoft.Extensions.Caching.Abstractions (>= 7.0.0 && < 8.0.0)
- Microsoft.Extensions.Caching.Memory (>= 7.0.0 && < 8.0.0)
- Microsoft.Extensions.Configuration (>= 7.0.0 && < 8.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 7.0.0 && < 8.0.0)
- Microsoft.Extensions.DependencyInjection (>= 7.0.0 && < 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0 && < 8.0.0)
- Microsoft.Extensions.Identity.Stores (>= 7.0.20 && < 8.0.0)
- Microsoft.Extensions.Logging (>= 7.0.0 && < 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 7.0.1 && < 8.0.0)
- Microsoft.Extensions.Logging.Configuration (>= 7.0.0 && < 8.0.0)
- Microsoft.Extensions.Options (>= 7.0.1 && < 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 7.0.0 && < 8.0.0)
- Microsoft.Extensions.Primitives (>= 7.0.0 && < 8.0.0)
- Pomelo.EntityFrameworkCore.MySql (>= 7.0.0 && < 8.0.0)
- Sufficit.Asterisk.Utils (>= 1.26.906.1626)
- Sufficit.Base (>= 1.26.909.1726)
- Sufficit.Json (>= 1.26.906.1634)
- Sufficit.Utils (>= 1.26.909.1727)
- System.IO.Pipelines (>= 8.0.0 && < 10.0.0)
- System.Linq.Async (>= 6.0.3 && < 7.0.0)
- System.Linq.Async.Queryable (>= 6.0.3 && < 7.0.0)
- System.Text.Json (>= 8.0.5 && < 9.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Sufficit.EFData:
| Package | Downloads |
|---|---|
|
Sufficit.Communication
Package Description |
|
|
Sufficit.Statistics
Statistics collection and routing for the Sufficit platform: event-bus metric sink (StatisticsRuntime), VictoriaMetrics / InfluxDB / composite output providers and publication extensions. Extracted from sufficit-standard. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.26.909.1815 | 37 | 9/9/2026 |
| 1.26.909.1737 | 39 | 9/9/2026 |
| 1.26.812.621 | 273 | 8/12/2026 |
| 1.26.804.1510 | 193 | 8/4/2026 |
| 1.26.724.207 | 132 | 7/24/2026 |
| 1.26.722.1839 | 121 | 7/22/2026 |
| 1.26.702.1449 | 128 | 7/2/2026 |
| 1.26.701.1838 | 207 | 7/1/2026 |
| 1.26.701.1749 | 119 | 7/1/2026 |
| 1.26.621.1720 | 132 | 6/21/2026 |
| 1.26.616.1631 | 188 | 6/16/2026 |
| 1.26.612.2110 | 110 | 6/12/2026 |
| 1.26.612.2045 | 128 | 6/12/2026 |
| 1.26.604.2158 | 136 | 6/4/2026 |
| 1.26.529.1513 | 133 | 5/29/2026 |
| 1.26.526.1524 | 122 | 5/26/2026 |
| 1.26.504.2036 | 161 | 5/4/2026 |
| 1.26.504.1323 | 128 | 5/4/2026 |
| 1.26.430.2043 | 166 | 4/30/2026 |
| 1.26.415.353 | 156 | 4/15/2026 |