更改字段数据类型然后更新模型时出错。 [英] Errors when changing field data types then updating model.

查看:45
本文介绍了更改字段数据类型然后更新模型时出错。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

晚上好,

最近我一直在使用实体框架4.0。在创建一个简单的模型并从数据库(客户和联系人)创建之后,我回到了数据库,并将几个与电话号码相关的字段中的数据类型从nchar(max)更改为varchar(3)或varchar(4) 。框架创建了这样的字段,我个人喜欢varchar类型。无论如何,现在我面临错误列表中的错误,如下所示:

"错误2039:概念性侧属性'AreaCode'已经映射到类型为'nchar'的存储属性。如果概念侧属性映射到存储模型中的多个属性,请确保存储模型中的所有属性具有相同的类型。"

现在首先要做的事情。电话号码是一种复杂类型,由四个标量属性组成,AreaCode,Prefix,Suffix和Extension。我有四个错误。我在Notepad ++中打开了Model.edmx文件,发现那里没有指定手机字段。我在哪里可以更改数据类型的概念方面规范?对于有问题的字段,映射详细信息属性表中没有任何内容可编辑...任何帮助都将非常感激,因为此错误不会返回任何有用的搜索命中(据我所见)。

Cory

解决方案

从上面来看,目前尚不清楚为使模型进入这种状态所做的确切工作。但首先,您可以通过设置相应的构面,而不是更改数据库中的数据库类型,而不是更改它们。例如,您可以指定MaxLength为3或4以删除(max)声明。您还可以指定Unicode = false以使系统从nchar切换到char。您可以指定FixedLength = false以使其从char切换到varchar。
其次,您的edmx文件中肯定会指定四个字段。听起来你需要转到模型浏览器并展开"复杂类型"。节点,找到你的PhoneNumber复杂类型,展开它,然后从那里你可以选择四个标量属性。

如果这没有帮助,我们需要看你的模型......

Good evening,

Recently I have been mucking around with entity framework 4.0.  After creating a simple model and from that a database (Customers and Contacts), I went back to the database and changed the data types on several of the phone number related fields from nchar(max) to varchar(3) or varchar(4).  The framework created those fields like that, and I personally like the varchar type.  Regardless, now I am faced with errors in the error list as follows:

"Error 2039: The conceptual side property 'AreaCode' has already been mapped to a storage property with type 'nchar'. If the conceptual side property is mapped to multiple properties in the storage model, make sure that all the properties in the storage model have the same type."

Now first things first.  Phone number is a complex type consisting of four scalar properties, AreaCode, Prefix, Suffix, and Extension.  I have errors for all four.  I opened the Model.edmx file in Notepad++ and found that the phone fields are not specified in there.  Where can I change th conceptual side specification of the datatype?  Nothing is editable in the Mapping Details Property sheet for the Fields in question...  Any help would be much appreciated as this error doesn't return any helpful hits on searches (as far as I have seen).

Cory

解决方案

From the above, it is unclear exactly what has been done to get the model into this state. But first and foremost, rather than changing the database types in the database, you can change them from the model by setting the appropriate facets. For example, you can specify a MaxLength of 3 or 4 to remove the (max) declaration. You can also specify Unicode=false to have the system switch from nchar to char. You can specify FixedLength=false to have it switch from char to varchar.

Second, the four fields will certainly be specified in your edmx file. Sounds like you need to go to the model browser and expand the "Complex Types" node, find your PhoneNumber complex type, expand that, and from there you can select the four scalar properties.

If this does not help, we'd need to see your model...


这篇关于更改字段数据类型然后更新模型时出错。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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