PosInformatique.Foundations.MediaTypes.EntityFramework 1.0.0

Prefix Reserved
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package PosInformatique.Foundations.MediaTypes.EntityFramework --version 1.0.0
                    
NuGet\Install-Package PosInformatique.Foundations.MediaTypes.EntityFramework -Version 1.0.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="PosInformatique.Foundations.MediaTypes.EntityFramework" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PosInformatique.Foundations.MediaTypes.EntityFramework" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="PosInformatique.Foundations.MediaTypes.EntityFramework" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PosInformatique.Foundations.MediaTypes.EntityFramework --version 1.0.0
                    
#r "nuget: PosInformatique.Foundations.MediaTypes.EntityFramework, 1.0.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.
#:package PosInformatique.Foundations.MediaTypes.EntityFramework@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PosInformatique.Foundations.MediaTypes.EntityFramework&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=PosInformatique.Foundations.MediaTypes.EntityFramework&version=1.0.0
                    
Install as a Cake Tool

PosInformatique.Foundations.MediaTypes.EntityFramework

NuGet version NuGet downloads

Introduction

Provides Entity Framework Core integration for the MimeType value object from PosInformatique.Foundations.MediaTypes. This package enables seamless mapping of MIME types as strongly-typed properties in Entity Framework Core entities.

It ensures proper SQL type mapping, validation, and conversion to VARCHAR(128) when persisted to the database.

Install

You can install the package from NuGet:

dotnet add package PosInformatique.Foundations.MediaTypes.EntityFramework

This package depends on the base package PosInformatique.Foundations.MediaTypes.

Features

  • Provides an extension method IsMimeType() to configure EF Core properties for MimeType.
  • Maps to VARCHAR(128) database columns using the SQL type MimeType (you must define the SQL type MimeType mapped to VARCHAR(128) in your database).
  • Ensures validation and safe conversion to/from database fields.
  • Built on top of the core MimeType value object.

Use cases

  • Entity mapping: enforce strong typing for MIME types at the persistence layer.
  • Consistency: ensure the same rules are applied in your entities and database.
  • Safety: prevent invalid or malformed MIME type strings being stored in your database.

Examples

⚠️ To use IsMimeType(), you must first define the SQL type MimeType mapped to VARCHAR(128) in your database. For SQL Server, you can create it with:

CREATE TYPE MimeType FROM VARCHAR(128) NOT NULL;

Example: Configure an entity

using Microsoft.EntityFrameworkCore;
using PosInformatique.Foundations.MediaTypes;

public class Document
{
    public int Id { get; set; }

    public MimeType ContentType { get; set; }
}

public class ApplicationDbContext : DbContext
{
    public DbSet<Document> Documents => Set<Document>();

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Document>()
            .Property(d => d.ContentType)
            .IsMimeType();
    }
}

This will configure the ContentType property of the Document entity with:

  • VARCHAR(128) (non-unicode) column length
  • SQL column type MimeType
  • Proper conversion between MimeType and string
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.  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. 
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
1.1.0-rc.2 49 1/26/2026
1.1.0-rc.1 52 1/23/2026
1.0.0 430 11/19/2025
1.0.0-rc.4 369 11/19/2025
1.0.0-rc.3 373 11/18/2025
1.0.0-rc.2 379 11/18/2025
1.0.0-rc.1 377 11/18/2025

1.0.0
 - Initial release with the support Entity Framework persitance for MimeType value object.