using System;
using AMWD.Common.EntityFrameworkCore.Converters;
using Microsoft.EntityFrameworkCore;
namespace AMWD.Common.EntityFrameworkCore.Extensions
{
///
/// Extensions for the of entity framework core.
///
public static class ModelConfigurationBuilderExtensions
{
///
/// Adds converters for the datatype introduced with .NET 6.0.
///
///
/// As of 2022-06-04 only required for Microsoft SQL server on .NET 6.0.
///
/// The instance.
/// The instance after applying the converters.
public static ModelConfigurationBuilder AddDateOnlyConverters(this ModelConfigurationBuilder builder)
{
builder.Properties()
.HaveConversion()
.HaveColumnType("date");
builder.Properties()
.HaveConversion()
.HaveColumnType("date");
return builder;
}
///
/// Adds converters for the datatype introduced with .NET 6.0.
///
///
/// As of 2022-06-04 only required for Microsoft SQL server on .NET 6.0.
///
/// The instance.
/// The instance after applying the converters.
public static ModelConfigurationBuilder AddTimeOnlyConverters(this ModelConfigurationBuilder builder)
{
builder.Properties()
.HaveConversion()
.HaveColumnType("time");
builder.Properties()
.HaveConversion()
.HaveColumnType("time");
return builder;
}
}
}