实体框架模型首先十进制精度 [英] Entityframework model first decimal precision

查看:300
本文介绍了实体框架模型首先十进制精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次使用Entityframework 6。在图中,我为数据类型选择了十进制。当我保存十进制值时,数据库只有整数,小数被删除。



我的第一个怀疑是检查精度,但是从属性窗口模型第一张图表设计师,精度和比例下拉菜单除无之外没有其他选项。



如何让EF保存我的小数位?这是一个精确的问题吗?如果是这样,在这种情况下如何设置精度?

解决方案

OK我觉得有点傻, ,但这是一个简单的修复。



在edmx设计器的列的属性窗口中,精度和缩放都是一个下拉菜单,但它仍然允许您输入它。所以我只是打了2进入规模,点击进入,它的工作。



不知道为什么他们设置为一个下拉,如果他们不提供你具有任何预设值,并期望您输入。


I'm using Entityframework 6 with model first. In the diagram I have chosen decimal for my datatype. When I save decimal values, the database only has whole numbers and the decimals get dropped.

My first suspicion was to check the precision, however going to the properties window from the model first diagram designer, the precision and scale dropdowns have no other options besides "None".

How do I get EF to save my decimals? Is it a precision issue? If so, how do I set the precision in this case?

解决方案

OK I feel a little silly for not figuring this out earlier, but this is a simple fix.

In the properties window for the column in the edmx designer, both precision and scale are a drop down menu, however it still lets you type in it. So I just typed 2 in for scale, hit enter, and it worked.

Not sure why they have it setup to be a drop down if they don't provide you with any preset values and expect you to type it in.

这篇关于实体框架模型首先十进制精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆