【译】第17节---数据注解-Column
Column属性可以应用于类的属性。 默认Code First约定创建与名称相同的列名称。 Column 属性覆盖此默认约定。 EF Code-First将在给定属性的Column属性中创建一个具有指定名称的列。
请看以下示例:
using System.ComponentModel.DataAnnotations.Schema; public class Student
{
public Student()
{ }
public int StudentID { get; set; } [Column("Name")]
public string StudentName { get; set; } }
如上例所示,Column属性应用于Student类的StudentName属性。 因此,Code-First将覆盖默认约定,并在Student表中创建Name列而不是StudentName列,如下所示:

你还可以使用Column属性指定列的顺序和类型,如下所示:
using System.ComponentModel.DataAnnotations.Schema; public class Student
{
public Student()
{ }
public int StudentID { get; set; } [Column("Name", Order=, TypeName="varchar")]
public string StudentName { get; set; } }
上面的代码创建了一个varchar类型的Name列作为Student中的第一列,如下所示:

【译】第17节---数据注解-Column的更多相关文章
- 【译】第10节---数据注解-Key
		原文:http://www.entityframeworktutorial.net/code-first/key-dataannotations-attribute-in-code-first.asp ... 
- 【译】第20节---数据注解-InverseProperty
		原文:http://www.entityframeworktutorial.net/code-first/inverseproperty-dataannotations-attribute-in-co ... 
- 【译】第19节---数据注解-NotMapped
		原文:http://www.entityframeworktutorial.net/code-first/notmapped-dataannotations-attribute-in-code-fir ... 
- 【译】第18节---数据注解-ForeignKey
		原文:http://www.entityframeworktutorial.net/code-first/foreignkey-dataannotations-attribute-in-code-fi ... 
- 【译】第16节---数据注解-Table
		原文:http://www.entityframeworktutorial.net/code-first/table-dataannotations-attribute-in-code-first.a ... 
- 【译】第15节---数据注解-StringLength
		原文:http://www.entityframeworktutorial.net/code-first/stringlength-dataannotations-attribute-in-code- ... 
- 【译】第14节---数据注解-MaxLength/MinLength
		原文:http://www.entityframeworktutorial.net/code-first/maxlength-minlength-dataannotations-attribute-i ... 
- 【译】第13节---数据注解-Required
		原文:http://www.entityframeworktutorial.net/code-first/required-attribute-dataannotations-in-code-firs ... 
- 【译】第12节---数据注解-ConcurrencyCheck
		原文:http://www.entityframeworktutorial.net/code-first/concurrencycheck-dataannotations-attribute-in-c ... 
随机推荐
- jQuery图片懒加载插件jquery.lazyload.js使用实例注意事项说明
			jQuery图片懒加载插件jquery.lazyload.js使用实例注意事项说明 jquery.lazyload.js是一个用JavaScript编写的jQuery插件.它可以延迟加载长页面中的图片 ... 
- [转载]ViewPort <meta>标记
			ViewPort <meta>标记用于指定用户是否可以缩放Web页面,如果可以,那么缩放到的最大和最小缩放比例是什么.使用 ViewPort <meta>标记还表示文档针对移动 ... 
- Different between MB SD Connect Compact 5 and MB SD C4 Star Diagnostic Tool
			MB SD C4 Star Diagnostic Tool is the professional MB Star Diagnostic Tools for benz cars and trucks. ... 
- #mxnet# 权值共享
			https://www.cnblogs.com/chenyliang/p/6847744.html Note:后记此权值共享非彼卷积共享.说的是layer实体间的参数共享. Introduction ... 
- Subversion版本控制系统的安装和操作.
			SVN的简单介绍 SVN是Subversoin的简称,是一个开源的版本控制系统 Subversion将文件存放在中心版本库里,这个版本库很像一个普通的文件服务器,不同的是,他可以记录每一次文件和目录的 ... 
- linux时间修改-hwclock和date
			修改系统时间date 设定日期:date -s 月/日/年,例如设定日期为2018年12月1日,date -s 12/01/2018(年也可以是两位) 设定时间:date -s hh:mm:ss,例如 ... 
- 【ASP.Net MVC3 】使用Unity 实现依赖注入
			转载于:http://www.cnblogs.com/techborther/archive/2012/01/06/2313498.html 家人身体不太好,好几天没在园子里发帖了. 新项目还是要用M ... 
- paymob浙江正和
			#region 上海 ZH //else if (order.SP.Contains("上海") && order.Area.Contains("移动&q ... 
- CCF 推荐国际国内会议及中文核心期刊要目总览
			CCF 推荐国际国内会议及<中文核心期刊要目总览> Ref :http://www.ccf.org.cn/xspj/rgzn/ Notes: dblp 是一个好网站,上面有各种主要会议的论 ... 
- aircrack-ng后台跑包, 成功后自动发送邮件通知
			我的思路是直接用nohup守护进程输出结构到指定文件, 然后判断文件中"KEY FOUND"的字段. 启动aircrack-ng方式 nohup aircrack-ng -w /o ... 
