CodeFirstOptions.UseDateTimeAsDate is not working in EF Core 2.0.1

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
Zerda
Posts: 11
Joined: Wed 22 Jan 2014 00:16

CodeFirstOptions.UseDateTimeAsDate is not working in EF Core 2.0.1

Post by Zerda » Mon 05 Feb 2018 08:40

Hi, it's me again. I am aware only a part of Entity Framework provider configuration settings is supported for Entity Framework Core.

But it would be nice to have a list which is supported which not.

When creating table with code first, UseDateTimeAsDate seems not working, the column type still be timestamp(7) not date.

Here is a small sample.

Code: Select all

class Program
{
    static void Main(string[] args)
    {
        var config = OracleEntityProviderConfig.Instance;
        config.CodeFirstOptions.UseDateTimeAsDate = true;

        var context = new MyDbContext();
        context.Database.EnsureCreated();
    }
}

class MyDbContext : DbContext
{
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseOracle(@"REDACTED");
    }

    public DbSet<Product> Products { get; set; }
}

class Product
{
    [Key]
    public int Id { get; set; }

    public DateTime Created { get; set; }
}

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: CodeFirstOptions.UseDateTimeAsDate is not working in EF Core 2.0.1

Post by Shalex » Thu 08 Feb 2018 11:08

Zerda wrote:I am aware only a part of Entity Framework provider configuration settings is supported for Entity Framework Core.

But it would be nice to have a list which is supported which not.
Thank you for your suggestion. There is no such a list at the moment.
Zerda wrote:When creating table with code first, UseDateTimeAsDate seems not working, the column type still be timestamp(7) not date.
We will notify you when UseDateTimeAsDate is supported in EF Core.

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: CodeFirstOptions.UseDateTimeAsDate is not working in EF Core 2.0.1

Post by Shalex » Thu 15 Feb 2018 18:02

The config.CodeFirstOptions.UseDateTimeAsDate option is supported in EF Core: viewtopic.php?f=1&t=36602.

Zerda
Posts: 11
Joined: Wed 22 Jan 2014 00:16

Re: CodeFirstOptions.UseDateTimeAsDate is not working in EF Core 2.0.1

Post by Zerda » Mon 14 May 2018 08:59

Yes, It's working with DateTime type, but not Nullable<DateTime>.

Would you please take look at this, thank you again.

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: CodeFirstOptions.UseDateTimeAsDate is not working in EF Core 2.0.1

Post by Shalex » Thu 17 May 2018 12:36

Thank you for your report. We will notify you when the issue is fixed.

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: CodeFirstOptions.UseDateTimeAsDate is not working in EF Core 2.0.1

Post by Shalex » Fri 25 May 2018 16:29

The bug with the DateTime? properties, when config.CodeFirstOptions.UseDateTimeAsDate is set to True, in EF Core is fixed: viewtopic.php?f=1&t=37215.

Post Reply