- ABP Framework version: v7.2
- UI type: Angular
- DB provider: EF Core
I'm trying to create an entity with a DateOnly field type, but when creating a migration I'm getting the following message:
The 'DateOnly?' property 'AccountingDeposit.BankPostingDate' could not be mapped to the database type 'date' because the database provider does not support mapping 'DateOnly?' properties to 'date' columns. Consider mapping to a different database type or converting the property value to a type supported by the database using a value converter. See https://aka.ms/efcore-docs-value-converters for more information. Alternately, exclude the property from the model using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.
I'm using a value converter as suggested.
protected override void ConfigureConventions(ModelConfigurationBuilder builder)
{
builder.Properties<DateOnly>()
.HaveConversion<DateOnlyConverter>()
.HaveColumnType("date");
base.ConfigureConventions(builder);
}
Please advice on how to proceed.
1 Answer(s)
-
0
Hi there,
what DBMS do you use? (MySql, Mssql, PostgreSQL)
Nevertheless you should not need to provide that convenstion override and specify the DateOnlyConverter for DateOnly Props.
I created a fresh application (ABP Framework Version 7.2.2) using MySql as DBMS and added a TestEntity with nullable DateOnly Property:
public class NullableDateOnlyTestEntity : AggregateRoot<Guid> { public DateOnly? ValidFrom { get; set; } }After adding the DbSet for this entity, the migration could be created without specifing the value converter. Here is the resulting Migration:

As you can see the db column type would be date.
So please try to create the migration again without specifying the exact value converter.
Greetings Nico
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)