【译】第16节---数据注解-Table
原文:http://www.entityframeworktutorial.net/code-first/table-dataannotations-attribute-in-code-first.aspx
Table 属性可以应用于一个类。 默认Code First约定创建与名称相同的表名称。Table属性覆盖此默认约定。 EF Code First将在给定域类的Table属性中创建一个具有指定名称的表。
请看以下示例:
using System.ComponentModel.DataAnnotations.Schema; [Table("StudentMaster")]
public class Student
{
public Student()
{ }
public int StudentID { get; set; } public string StudentName { get; set; } }
如上例所示,Table属性应用于Student类。 因此,Code First将覆盖默认约定,并创建StudentMaster表而不是Student表,如下所示:
你还可以使用Table属性指定表的模式(schema ),如下所示:
using System.ComponentModel.DataAnnotations.Schema; [Table("StudentMaster", Schema="Admin")]
public class Student
{
public Student()
{ }
public int StudentID { get; set; } public string StudentName { get; set; } }
Code-First将在Admin模式中创建StudentMaster表,如下所示:
【译】第16节---数据注解-Table的更多相关文章
- 【译】第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 ...
- 【译】第17节---数据注解-Column
原文:http://www.entityframeworktutorial.net/code-first/column-dataannotations-attribute-in-code-first. ...
- 【译】第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 ...
- 【译】第11节---数据注解-TimeStamp
原文:http://www.entityframeworktutorial.net/code-first/TimeStamp-dataannotations-attribute-in-code-fir ...
随机推荐
- python os.path.expanduser()
# Expand the user's home directory
- QThread详解
回顾Qt之线程(QThread),里面讲解了如何使用线程,但还有很多人留言没有看明白,那么今天我们来一起瞅瞅关于QThread管理线程的那些事儿... 一.线程管理 1.线程启动 void start ...
- Shell for while 循环
li@ubuntu:~/test$ cat a.sh #!/bin/bash for loop in 1 2 3 4 5 do echo "The value is : $loop" ...
- 动态创建生成lambd表达式
基于网上找的一段代码进行修改,目前扩展了NotContains方法的实现 using System; using System.Collections.Generic; using System.Co ...
- TCP协议、算法和原理
TCP是一个巨复杂的协议,因为他要解决很多问题,而这些问题又带出了很多子问题和阴暗面.所以学习TCP本身是个比较痛苦的过程,但对于学习的过程却能让人有很多收获. 关于TCP这个协议的细节,我还是推荐你 ...
- 前端框架VUE----表单输入绑定
vue的核心:声明式的指令和数据的双向绑定. 那么声明式的指令,已经给大家介绍完了.接下来我们来研究一下什么是数据的双向绑定? 另外,大家一定要知道vue的设计模式:MVVM M是Model的简写,V ...
- ogg 12.3 中 format release的变化
Non-CDB databases with compatibility set to 12.1, FORMAT RELEASE 12.2 or above is supported. Non-CDB ...
- 怎样从外网访问内网Oracle数据库?
本地安装了一个Oracle数据库,只能在局域网内访问到,怎样从外网也能访问到本地的Oracle数据库呢?本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动Oracle数据库 默认安装的Or ...
- n个整数中1出现的次数
整数中1出现的次数(从1到n整数中1出现的次数) (两种方法:1.规律.2暴力求解) 题目描述 求出1 ~ 13的整数中1出现的次数,并算出100 ~ 1300的整数中1出现的次数?为此他特别数了一下 ...
- Failed to load ApplicationContext
java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.conte ...