環(huán)境:sqlserver 2017 ,.net core 2.0,EF core 2.01.數(shù)據(jù)庫(kù)中字段類(lèi)型是float的(可空),對(duì)應(yīng)實(shí)體類(lèi)型也是用的float的(可空),程序啟動(dòng)起來(lái)就報(bào)錯(cuò),日志詳情為:An exception occurred while reading a database value for property 'XXXXXX'. The expected type was 'System.Nullable`1[System.Single]' but the actual value was of type 'System.Double'. ---> System.InvalidCastException: Unable to cast object of type 'System.Double' to type 'System.Nullable`1[System.Single]'.于是我把字段類(lèi)型改為Double解決了。很好奇這個(gè)問(wèn)題的原因是什么??還有順便問(wèn)一下double和Double有什么不同??
添加回答
舉報(bào)
0/150
提交
取消