MVC3命名以数字开头的列 [英] MVC3 naming a column beginning with a number

查看:204
本文介绍了MVC3命名以数字开头的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来MVC3 C#。我需要有一个名为 3DSecureStatus 遗留目的数据库中的列。

I am new to MVC3 C#. I need to have a column in the database called 3DSecureStatus for legacy purposes.

当我打电话列这一点,插入应用程序中我得到这个错误:

When I call the column this and insert in the application I get this error:

[ModelValidationException:一个或多个验证错误模型生成过程中检测到

[ModelValidationException: One or more validation errors were detected during model generation:

System.Data.Edm.EdmProperty:名称:指定的名称是不允许的:
'_3DSecureStatus。 ]

System.Data.Edm.EdmProperty: Name: The specified name is not allowed: '_3DSecureStatus'. ]

在该应用程序,我把它定义为公共字符串_3DSecureStatus {搞定;组; } ,因为它不喜欢 3 被列名的第一个字符。

In the application I am defining it as public string _3DSecureStatus { get; set; } because it doesn't like 3 being the first character of the column name.

任何建议,该怎么办?

推荐答案

使用的属性来指定数据库列名

Use the Column attribute to specify the database column name

[Column("3DSecureStatus")]
public string ThreeDSecureStatus { get; set; }



或者使用流利的映射像

Or use fluent mapping like

Property(x => x.ThreeDSecureStatus).HasColumnName("3DSecureStatus");

这篇关于MVC3命名以数字开头的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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