【译】第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 ...
 
随机推荐
- Mysql相关技术细节整理
			
一.错误日志相关 1.mysql错误日志所在位置 windows下,错误日志文件一般在安装目录下的data目录下.扩展名是.err的文件,也可以打开安装目录下的my.ini文件检查一下linux下,错 ...
 - 转:wcf大文件传输解决之道(1)
			
首先声明,文章思路源于MSDN中徐长龙老师的课程整理,加上自己的一些心得体会,先总结如下: 在应对与大文件传输的情况下,因为wcf默认采用的是缓存加载对象,也就是说将文件包一次性接受至缓存中,然后生成 ...
 - Oracle 数据库实现数据合并:merge
			
1.使用update进行数据更新 1)最简单的更新 update tablea a set a.price=1.00 2)带条件的数据更新 update tablea a set a.price = ...
 - pytest+request 接口自动化测试
			
1.安装python3brew update brew install pyenv 然后在 .bash_profile 文件中添加 eval “$(pyenv init -)” pyenv insta ...
 - LINUX搭建PySpider爬虫服务
			
1.环境搭建 yum update -y yum install gcc gcc-c++ -y yum install python-pip python-devel python-distribut ...
 - ubuntu_python_environment
			
参考:http://blog.csdn.net/kingppy/article/details/13080919 参考:http://blog.csdn.net/zhaobig/article/det ...
 - 模型(model-->orm)系统
			
一.ORM介绍 1)ORM概念 对象关系映射(Object Relational Mapping,简称ORM)模式是一种为了解决面向对象与关系数据库存在的互不匹配的现象的技术. 简单的说,ORM是通过 ...
 - 用Java实现MVPtree——MVPtree点集内去重以及衍生出来的多维向量Hash问题
			
上次完成了MVPtree之后,客户又提出了MVPtree点集元素重复的问题,希望我将元素去重. 集合去重哪家强?java.util找HashSet!如果不计较元素顺序,放进去基本就没有重复元素了. 只 ...
 - mysql配置主从复制和常见问题
			
克隆192.168.138.130(主库),修改后的ip为192.168.138.130(从库),修改131机器的/etc/udev/rules.d/70-persistent-net.rules,将 ...
 - k8s (kubernetes) 代码分析
			
简易入门 结构图: debug 先了解 etcd API源码分析 API server 是中心. https://www.jianshu.com/p/88c6ed78b668 $ git ls-fil ...