简体   繁体   中英

Entity Framework does not map columns that are defined as Decimal

I have a hard time understanding why Entity Framework skips columns that are defined as decimal. I've tried deleting the model a couple of times and adding it back using the database first approach but for some reason a few columns are not mapped.

The ones that are defined as Date , Int or Text have absolutely no problem. The ones that are giving me a hard time are the decimal ones and I have defined them as such:

  • Name: Hours, Datatype: Decimal, Length/Set: 10,2, Unsigned: Checked, Allow Null: Unckecked, Zerofill: Unchecked, Default value: 0.00.

If I create a view with sums based on that same table, EF has no problem identifying the decimal columns. How can I add the missing columns to my model? What am I doing wrong and is there a workaround?

Thank you

After spending hours on this I finally figured it out. If you are facing the same problem make sure that your column are not UNSIGNED .

For some reason Entity Framework does not map decimal columns that are unsigned. Just uncheck that option and you should be good.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM