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.”

 

posted @ 2019-09-18 10:38  China-Liu  阅读(1289)  评论(0编辑  收藏  举报