Entity Framework Code-First(9.7):DataAnnotations - Table Attribute
DataAnnotations - Table Attribute:
Table attribute can be applied to a class. Default Code-First convention creates a table name same as the class name. Table attribute overrides this default convention. EF Code-First will create a table with a specified name in Table attribute for a given domain class.
Consider the following example.
using System.ComponentModel.DataAnnotations.Schema; [Table("StudentMaster")]
public class Student
{
public Student()
{ }
public int StudentID { get; set; } public string StudentName { get; set; } }
As you can see in the above example, Table attribute is applied to Student class. So, Code First will override default conventions and create StudentMaster table instead of Student table as shown below.
You can also specify a schema for the table using Table attribute as shown below.
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 will create StudentMaster table in Admin schema as shown below.
Entity Framework Code-First(9.7):DataAnnotations - Table Attribute的更多相关文章
- Entity Framework Code-First(9.6):DataAnnotations - StringLength Attribute
DataAnnotations - StringLength Attribute: StringLength attribute can be applied to a string type pro ...
- Entity Framework Code-First(9.5):DataAnnotations - MaxLength Attribute
DataAnnotations - MaxLength Attribute: MaxLength attribute can be applied to a string or array type ...
- Entity Framework Code-First(9.10):DataAnnotations - NotMapped Attribute
DataAnnotations - NotMapped Attribute: NotMapped attribute can be applied to properties of a class. ...
- Entity Framework Code-First(9.9):DataAnnotations - ForeignKey Attribute
DataAnnotations - ForeignKey Attribute: ForeignKey attribute can be applied to properties of a class ...
- Entity Framework Code-First(9.8):DataAnnotations - Column Attribute
DataAnnotations - Column Attribute: Column attribute can be applied to properties of a class. Defaul ...
- Entity Framework Code-First(9.2):DataAnnotations - TimeStamp Attribute
DataAnnotations - TimeStamp Attribute: TimeStamp attribute can be applied to only one byte array pro ...
- Entity Framework Code-First(9.1):DataAnnotations - Key Attribute
DataAnnotations - Key Attribute: Key attribute can be applied to properties of a class. Default Code ...
- Entity Framework Code-First(9.4):DataAnnotations - Required Attribute
Required attribute can be applied to a property of a domain class. EF Code-First will create a NOT N ...
- Entity Framework Code-First(9.3):DataAnnotations - ConcurrencyCheck Attribute
ConcurrencyCheck Attribute: ConcurrencyCheck attribute can be applied to a property of a domain clas ...
随机推荐
- JS饼状图表数据分布插件
在线演示 本地下载
- 使用Pydoc生成文档
Python中本身带有很多实用的工具,如pydoc.pydoc模块主要用来从Python模块中提取信息并生成文档. 使用方法 在Windows和Linux下的使用方法有些区别. Windows pyt ...
- Windows下Nginx的启动、停止等命令添加
Windows下Nginx的启动.停止等命令在Windows下使用Nginx,我们需要掌握一些基本的操作命令,比如:启动.停止Nginx服务,重新载入Nginx等,下面我就进行一些简单的介绍.1.启动 ...
- css3 点击爆炸下落
代码][JavaScript]代码 $(document).ready(function() { // Generate the clips. In this case ...
- sqlserver 函数里并返回一个表格数据拼接的字符串
Create function [dbo].[GetChildWorkerExtension]( @ChildId int)returns nvarchar(100)asbegin ...
- vue2.0+wechat
首先遇到的问题就是使用npm下载JSSDK 下载正确的JSSDK 正确的名称是:'weixin-js-sdk' 其实有好几个相似的名称都可以下载,只有这一个能用 支付问题使用Vue的路由跳转到支付页面 ...
- 英语发音规则---ea字母组合发音规律
英语发音规则---ea字母组合发音规律 一.总结 一句话总结:字母组合ea的发音规律,在学习字母组合在单词中的发音规律以前,一定要熟练撑握什么是开音节,什么是闭音节,否则你就不撑握这些发音规律. ea ...
- 常用的MySQL语句写法
常用的MySQL语句写法 MySQL的SQL语句写法,除了那些基本的之外,还有一些也算比较常用的,这里记录下来,以便以后查找. 好记性不如烂笔头,这话说的太有道理了,一段时间不写它,还真容易忘 ...
- hdu 1503 Advanced Fruits(最长公共子序列)
Advanced Fruits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- 开发人员需要具备的DBA技术
背景 在一些小公司或者部门里,通常很少有专门的DBA职位.这时候就需要我们这些程序员充当业余DBA的作用,去监测和维护数据库性能.本文的目的是帮助非DBA专业的开发人员如何定位和解决日常出现数据库问题 ...