代码第一列,类型为char(36) [英] Code first columns with type char(36)

查看:108
本文介绍了代码第一列,类型为char(36)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个UserProfile模型类作为SimpleMembership的一部分。在其中,我需要存储另一个类型为$ code> char(36)的数据库中的遗留标识符。我很乐意把这个改成一个比较独特的标识符更合理的东西,但是今天的活动不合适。



我当前的注释创建了一个列 nvarchar(36)

  [StringLength(36)] 
public string UserIdentifier {get ;组;我想要一列 char(36)这是可能的吗?

解决方案

如果你想保留数据注释,那么只需使用:

  [StringLength(36)] 
[Column(TypeName =char)]
public string UserIdentifier {get;组; }


So I have a UserProfile model class as part of SimpleMembership. In it I need to store a legacy identifier that exists in another DB of type char(36). I'd love to change this to something more sensible like a uniqueIdentifier but that's out of scope for today's activities.

My current annotation creates a column nvarchar(36)

[StringLength(36)]
public string UserIdentifier{ get; set; }

I'd like a column of char(36) instead. Is this possible?

解决方案

If you want to keep with Data Annotations, then just simply use:

[StringLength( 36 )]
[Column( TypeName = "char" )]
public string UserIdentifier{ get; set; }

这篇关于代码第一列,类型为char(36)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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