question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type 'Nullable<DateTime>' is not supported by current database provider

See original GitHub issue

Hi,

I have this model:

public class Advertisement
{
    public int AdvertisementId { get; set; }
    ...
    public DateTime? AvailableDate { get; set; }
    public DateTime? StartDate { get; set; }
    public DateTime? EndDate { get; set; }
}

On the ApplicationDbContext under OnModelCreating I have the following code:

builder.Property(p => p.AvailableDate).IsRequired(false).HasColumnType("date");

When I try dotnet ef migrations add initial_migration I get the following error:

The property 'Advertisement.AvailableDate' is of type 'Nullable<DateTime>' which is not supported by current database provider. Either change the property CLR type or ignore the property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

What I am doing wrong here? Thank you for your help…

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
YohDeadfallcommented, Jul 11, 2018

Related npgsql/npgsql#1965. Will fix it in the upcoming weekend.

0reactions
rojicommented, Aug 2, 2018

Closing as no additional info was provided within 7 days. But please feel free to post back here with the relevant information and I’ll reopen if necessary.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The property X is of type Y which is not supported by ...
I get the error: InvalidOperationException: The property 'Branch.Address' is of type 'Address' which is not supported by current database ...
Read more >
Entity Framework Core: System.InvalidOperationException ...
InvalidOperationException: The property X is of type Y which is not supported by current database provider. Either change the property CLR ...
Read more >
DateOnly and TimeOnly support with Entity Framework Core 6.0
This happens because the underlying provider, Microsoft. Data. SqlClient, does not supported them neither, as described on a GitHub issue.
Read more >
Value Conversions - EF Core
The provider type is the .NET type understood by the database provider. ... A null value will never be passed to a value...
Read more >
Entity Properties - EF Core
C# 8 introduced a new feature called nullable reference types (NRT), which allows reference types to be annotated, indicating whether it is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found