PosInformatique.Foundations.MediaTypes.EntityFramework
1.0.0
Prefix Reserved
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
<PackageReference Include="PosInformatique.Foundations.MediaTypes.EntityFramework" Version="1.0.0" />
<PackageVersion Include="PosInformatique.Foundations.MediaTypes.EntityFramework" Version="1.0.0" />
<PackageReference Include="PosInformatique.Foundations.MediaTypes.EntityFramework" />
paket add PosInformatique.Foundations.MediaTypes.EntityFramework --version 1.0.0
#r "nuget: PosInformatique.Foundations.MediaTypes.EntityFramework, 1.0.0"
#:package PosInformatique.Foundations.MediaTypes.EntityFramework@1.0.0
#addin nuget:?package=PosInformatique.Foundations.MediaTypes.EntityFramework&version=1.0.0
#tool nuget:?package=PosInformatique.Foundations.MediaTypes.EntityFramework&version=1.0.0
PosInformatique.Foundations.MediaTypes.EntityFramework
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 forMimeType. - Maps to
VARCHAR(128)database columns using the SQL typeMimeType(you must define the SQL typeMimeTypemapped toVARCHAR(128)in your database). - Ensures validation and safe conversion to/from database fields.
- Built on top of the core
MimeTypevalue 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 typeMimeTypemapped toVARCHAR(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
MimeTypeandstring
Links
| 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 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. |
-
net8.0
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.0)
- PosInformatique.Foundations.MediaTypes (>= 1.0.0)
-
net9.0
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.0)
- PosInformatique.Foundations.MediaTypes (>= 1.0.0)
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.