EntityFramework6.Npgsql - 如何读取类型为“不带时区的时间”的列

问题描述 投票:0回答:1

我有一个 postgresql 数据库,我使用 Entity Framework 6 和 Npgsql 连接到该数据库。我的表有一列带有定义

time_column time without time zone

我正在尝试使用实体框架将其读取到属性

[Column("time_column")]
public TimeSpan Time{ get; set; }

但是,当我尝试读取该表时,我收到错误

UNION types interval and time without time zone cannot be matched

我应该如何在 EF 类中配置该列的属性?

c# entity-framework entity-framework-6 npgsql
1个回答
0
投票

使用 TimeOnly 输入您的属性:

public TimeOnly TimeProp { get; set; }
© www.soinside.com 2019 - 2024. All rights reserved.