Franz.Common.EntityFramework
1.2.62
dotnet add package Franz.Common.EntityFramework --version 1.2.62
NuGet\Install-Package Franz.Common.EntityFramework -Version 1.2.62
<PackageReference Include="Franz.Common.EntityFramework" Version="1.2.62" />
paket add Franz.Common.EntityFramework --version 1.2.62
#r "nuget: Franz.Common.EntityFramework, 1.2.62"
// Install Franz.Common.EntityFramework as a Cake Addin #addin nuget:?package=Franz.Common.EntityFramework&version=1.2.62 // Install Franz.Common.EntityFramework as a Cake Tool #tool nuget:?package=Franz.Common.EntityFramework&version=1.2.62
Franz.Common.EntityFramework
A comprehensive library within the Franz Framework, designed to extend and simplify the integration of Entity Framework Core in .NET applications. This package provides additional features, abstractions, and utilities for managing relational and NoSQL databases, including support for Cosmos DB and MongoDB.
Features
- Database Configurations:
- Flexible configurations for Cosmos DB (
CosmosDBConfig
) and MongoDB (MongoDBConfig
). - Centralized management of database options (
DatabaseOptions
).
- Flexible configurations for Cosmos DB (
- Repositories:
- Abstractions for data persistence:
ReadRepository
: For querying read-only data.AggregateRepository
: For managing aggregates in domain-driven design.
- Abstractions for data persistence:
- Multi-Database Context:
- Support for multiple database contexts (
DbContextMultiDatabase
).
- Support for multiple database contexts (
- Behaviors:
PersistenceBehavior
for managing transactional and persistence concerns.
- Conversions:
EnumerationConverter
: Converts enumerations to database-friendly formats.
- Extensions:
MediatorExtensions
: Extensions for MediatR.ModelBuilderExtensions
: Simplify model configuration.ServiceCollectionExtensions
: Streamlined dependency injection setup.
Version Information
- Current Version: 1.2.62
- Part of the private Franz Framework ecosystem.
Dependencies
This package relies on:
- Microsoft.EntityFrameworkCore (8.0.0): Core Entity Framework functionality.
- Microsoft.EntityFrameworkCore.Cosmos (8.0.0): Cosmos DB provider for EF Core.
- Microsoft.EntityFrameworkCore.Relational (8.0.0): Relational database provider for EF Core.
- Microsoft.Extensions.Configuration.Abstractions (8.0.0): For configuration management.
- Microsoft.Extensions.Hosting.Abstractions (8.0.0): Hosting abstractions for dependency injection.
- MongoDB.Driver (2.22.0): MongoDB .NET driver for NoSQL database interaction.
- Franz.Common.Business: DDD and CQRS support.
- Franz.Common.DependencyInjection: Simplified DI patterns.
- Franz.Common.Errors: Centralized error management.
- Franz.Common.MultiTenancy: Multi-tenancy support for databases.
- Franz.Common.Reflection: Advanced reflection utilities.
Installation
From Private Azure Feed
Since this package is hosted privately, configure your NuGet client:
dotnet nuget add source "https://your-private-feed-url" \
--name "AzurePrivateFeed" \
--username "YourAzureUsername" \
--password "YourAzurePassword" \
--store-password-in-clear-text
Install the package:
dotnet add package Franz.Common.EntityFramework --version 1.2.62
Usage
1. Configuring Database Contexts
Define a context using DbContextBase
or DbContextMultiDatabase
:
using Franz.Common.EntityFramework;
public class AppDbContext : DbContextBase
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
public DbSet<Order> Orders { get; set; }
}
2. Cosmos DB Configuration
Use the CosmosDBConfig
class to configure Cosmos DB:
using Franz.Common.EntityFramework.Configuration;
var cosmosConfig = new CosmosDBConfig
{
Endpoint = "https://cosmosdb-endpoint.documents.azure.com",
Key = "your-cosmos-key",
DatabaseName = "MyDatabase"
};
3. MongoDB Configuration
Configure MongoDB using MongoDBConfig
:
using Franz.Common.EntityFramework.Configuration;
var mongoConfig = new MongoDBConfig
{
ConnectionString = "mongodb://localhost:27017",
DatabaseName = "MyMongoDatabase"
};
4. Dependency Injection
Use ServiceCollectionExtensions
to register EF Core services:
using Franz.Common.EntityFramework.Extensions;
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer("YourConnectionString"));
services.AddCosmosDB(cosmosConfig);
services.AddMongoDB(mongoConfig);
}
}
5. Repositories
Leverage ReadRepository
or AggregateRepository
for querying and persistence:
using Franz.Common.EntityFramework.Repositories;
public class OrderRepository : ReadRepository<Order>
{
public OrderRepository(AppDbContext context) : base(context) { }
}
Integration with Franz Framework
The Franz.Common.EntityFramework library integrates seamlessly with:
- Franz.Common.Business: Enables DDD and CQRS patterns.
- Franz.Common.DependencyInjection: Simplifies DI setup for database services.
- Franz.Common.Errors: Provides standardized error handling.
Ensure these dependencies are installed to fully utilize the library.
Contributing
This package is part of a private framework. Contributions are limited to the internal development team. If you have access, follow these steps:
- Clone the repository.
- Create a feature branch.
- Submit a pull request for review.
License
This library is licensed under the MIT License. See the LICENSE
file for more details.
Changelog
Version 1.2.62
- Added support for Cosmos DB and MongoDB configurations.
- Introduced
DbContextMultiDatabase
for multi-database environments. - Added
PersistenceBehavior
for transactional support. - Integrated
EnumerationConverter
for enum handling in databases. - Streamlined DI with
ServiceCollectionExtensions
.
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. |
-
net8.0
- Franz.Common.Business (>= 1.2.62)
- Franz.Common.DependencyInjection (>= 1.2.62)
- Franz.Common.Errors (>= 1.2.62)
- Franz.Common.MultiTenancy (>= 1.2.62)
- Franz.Common.Reflection (>= 1.2.62)
- Microsoft.EntityFrameworkCore (>= 8.0.0)
- Microsoft.EntityFrameworkCore.Cosmos (>= 8.0.0)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- MongoDB.Driver (>= 2.22.0)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on Franz.Common.EntityFramework:
Package | Downloads |
---|---|
Franz.Common.MongoDB
Shared utility library for the Franz Framework. |
|
Franz.Common.EntityFramework.SQLServer
Shared utility library for the Franz Framework. |
|
Franz.Common.EntityFramework.MariaDB
Shared utility library for the Franz Framework. |
|
Franz.Common.SSO
Shared utility library for the Franz Framework. |
|
Franz.Common.EntityFramework.Oracle
Shared utility library for the Franz Framework. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.2.62 | 70 | 1/8/2025 |