Skip to content

Commit

Permalink
config: config nuget package
Browse files Browse the repository at this point in the history
  • Loading branch information
M0BIN-V committed Jan 1, 2025
1 parent a24f3bd commit 65338a5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 39 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.idea/
/Valobtify.Swagger.FastEndpoints/obj
/Valobtify.Swagger.FastEndpoints/bin
/Valobtify.Swagger.FastEndpoints/bin
/.vs/Valobtify.Swagger.FastEndpoints
37 changes: 0 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +0,0 @@
[![NuGet Package](https://img.shields.io/nuget/v/Valobtify.EntityFrameworkCore)](https://www.nuget.org/packages/Valobtify.EntityFrameworkCore/)

### Overview

`Valobtify.EntityFrameworkCore` is an extension of the `Valobtify` library that simplifies the configuration and persistence of single-value objects in Entity Framework Core. It automates the application of data annotations like `MaxLength` and handles type conversions, making your value objects database-ready with minimal setup.

---

### Installation

To install the `Valobtify.EntityFrameworkCore` package, run the following command in your terminal:

```bash
dotnet add package Valobtify.EntityFrameworkCore
```

Ensure you have the required .NET SDK installed.

---

### Setup Single-Value Objects

To configure single-value objects in your Entity Framework Core `DbContext`, override the `OnModelCreating` method as shown below:

```csharp
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.SetupSingleValueObjects();

base.OnModelCreating(modelBuilder);
}
```

**Explanation:**
- `SetupSingleValueObjects` automatically applies the necessary configurations for your single-value objects, including data annotations and type conversions.
- By calling this method, you ensure your value objects are properly mapped to the database schema.

2 changes: 1 addition & 1 deletion Valobtify.Swagger.FastEndpoints/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Valobtify.Swagger.FastEndpoints;

public static class Extensions
{
public static IEnumerable<Type> GetSingleValueObjectTypes(this Assembly assembly)
internal static IEnumerable<Type> GetSingleValueObjectTypes(this Assembly assembly)
{
var baseType = typeof(SingleValueObject<,>);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,30 @@
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Description>Integrate Valobtify with Swagger and FastEndpoints</Description>
<PackageLicenseFile>LICENCE</PackageLicenseFile>
<Title>Valobtify.EntityFrameworkCore</Title>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/Valobtify/Valobtify.Swagger.FastEndpoints</RepositoryUrl>
<PackageIcon>Valobtify_Logo.png</PackageIcon>
<Version>1.0.0</Version>
</PropertyGroup>

<ItemGroup>
<None Include="..\LICENCE">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\Valobtify_Logo.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="FastEndpoints" Version="5.33.0" />
<PackageReference Include="FastEndpoints.Swagger" Version="5.33.0" />
Expand Down
Binary file added Valobtify_Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 65338a5

Please sign in to comment.