OfX-EFCore 3.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package OfX-EFCore --version 3.1.0                
NuGet\Install-Package OfX-EFCore -Version 3.1.0                
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="OfX-EFCore" Version="3.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OfX-EFCore --version 3.1.0                
#r "nuget: OfX-EFCore, 3.1.0"                
#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.
// Install OfX-EFCore as a Cake Addin
#addin nuget:?package=OfX-EFCore&version=3.1.0

// Install OfX-EFCore as a Cake Tool
#tool nuget:?package=OfX-EFCore&version=3.1.0                

OfX.EntityFrameworkCore

OfX.EntityFrameworkCore is an extension package for OfX that integrates with Entity Framework Core to simplify data fetching by leveraging attribute-based data mapping. This extension streamlines data retrieval using EF Core, reducing boilerplate code and improving maintainability.

Demo Project!


Introduction

OfX.EntityFrameworkCore extends the core OfX library by providing seamless integration with Entity Framework Core. This enables developers to automatically map and retrieve data directly from a database, leveraging the power of EF Core along with attribute-based data mapping.

For example, suppose you have a UserId property in your model, and you want to fetch the corresponding UserName and Email fields from the database. By using OfX.EntityFrameworkCore, you can annotate your model with attributes, and the library will handle data fetching for you.


Installation

To install the OfX.EntityFrameworkCore package, use the following NuGet command:

dotnet add package OfX-EFCore

Or via the NuGet Package Manager:

Install-Package OfX-EFCore

How to Use

1. Register OfX.EntityFrameworkCore

Add OfX.EntityFrameworkCore to your service configuration during application startup:

builder.Services.AddOfXEntityFrameworkCore(cfg =>
{
    cfg.AddAttributesContainNamespaces(typeof(WhereTheAttributeDefined).Assembly);
    cfg.AddHandlersFromNamespaceContaining<SomeHandlerAssemblyMarker>();
})
.AddOfXEFCore(options =>
{
    options.AddDbContexts(typeof(TestDbContext));
    options.AddModelConfigurationsFromNamespaceContaining<SomeModelAssemblyMarker>();
});

After installing the package OfX-EFCore, you can use the method AddDbContexts(), which takes DbContext(s) to executing.

2. Mark the model you want to use with OfXAttribute

Example:

[OfXConfigFor<UserOfAttribute>(nameof(Id), nameof(Name))]
public class User
{
    public string Id { get; set; }
    public string Name { get; set; }
    public string Email { get; set; }
}

That all! Let go to the moon!

Note: Currently, the Id type is supported for primitive type, in the next version. The strongly-type should be supported!

Package Name Description .NET Version Document
OfX OfX core 8.0, 9.0 ReadMe
OfX-EFCore This is the OfX extension package using EntityFramework to fetch data 8.0, 9.0 This Document
OfX-gRPC OfX.gRPC is an extension package for OfX that leverages gRPC for efficient data transportation. 8.0, 9.0 ReadMe

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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.0.0 25 2/4/2025
3.3.3 64 2/4/2025
3.3.2 69 2/3/2025
3.3.1 62 2/1/2025
3.3.0 65 1/22/2025
3.2.1 67 1/22/2025
3.2.0 74 1/21/2025
3.1.13 68 1/18/2025
3.1.12 66 1/16/2025
3.1.11 70 1/13/2025
3.1.10 73 1/12/2025
3.1.9 77 1/10/2025
3.1.8 53 1/8/2025
3.1.7 73 1/7/2025
3.1.6 78 1/6/2025
3.1.5 81 1/5/2025
3.1.4 98 1/4/2025
3.1.3 101 1/4/2025
3.1.2 110 1/4/2025
3.1.1 110 1/3/2025
3.1.0 74 12/31/2024
3.0.5 79 12/30/2024
3.0.4 69 12/30/2024
3.0.3 77 12/30/2024
3.0.2 90 12/30/2024
3.0.1 81 12/30/2024
3.0.0 83 12/30/2024
2.0.4 79 12/30/2024
2.0.3 76 12/30/2024
2.0.2 80 12/29/2024
2.0.1 94 12/29/2024
2.0.0 89 12/28/2024
1.1.4 92 12/27/2024
1.1.3 78 12/26/2024
1.1.2 80 12/26/2024
1.1.1 78 12/26/2024
1.1.0 84 12/25/2024
1.0.8 88 12/25/2024
1.0.7 88 12/25/2024
1.0.6 79 12/25/2024