Oracle.EntityFrameworkCore使用时报错:Specified cast is not valid

我用的是:Oracle.EntityframeworkCore 2.19.30

如果看到报错:System.InvalidCastException:“Specified cast is not valid.

(1)可能是因为你的EntityModel中字段类型与数据表中字段的类型不一致引起的。

(2)Oracle中的Date类型,在EntityModel中请不要使用DateTimeOffset与之对应,否则也是报这个错误。请使用DateTime

例如:Db(A某字段为Number类型) Entity(A某字段为string类型)  那么就会报错:System.InvalidCastException:“Specified cast is not valid.”

原文地址:https://www.cnblogs.com/chinaliu/p/11540209.html