Index Attribute:

Entity Framework 6 provides Index attribute to create Index on a particular column in the database as shown below:

class Student
{
public Student()
{
} public int Student_ID { get; set; }
public string StudentName { get; set; } [Index]
public int RegistrationNumber { get; set; }
}

By default, Index name will be IX_{property name}. However, you can also change the Index name.

You can also make it a Clustered index by specifying IsClustered = true and a unique index by specifying IsUnique=true.

[Index( "INDEX_REGNUM", IsClustered=true, IsUnique=true )]
public int RegistrationNumber { get; set; }

Download Code-First sample project for Index attribute demo.

Entity Framework 6.0 Tutorials(10):Index Attribute的更多相关文章

  1. Entity Framework 6.0 Tutorials(1):Introduction

    以下系统文章为EF6.0知识的介绍,本章是第一篇 原文地址:http://www.entityframeworktutorial.net/entityframework6/introduction.a ...

  2. Entity Framework 6.0 Tutorials(4):Database Command Logging

    Database Command Logging: In this section, you will learn how to log commands & queries sent to ...

  3. Entity Framework 6.0 Tutorials(11):Download Sample Project

    Download Sample Project: Download a sample project for Entity Framework 6 Database-First model below ...

  4. Entity Framework 6.0 Tutorials(9):Stored Procedure Mapping

    Code First - Insert, Update, Delete Stored Procedure Mapping: Entity Framework 6 Code-First provides ...

  5. Entity Framework 6.0 Tutorials(6):Transaction support

    Transaction support: Entity Framework by default wraps Insert, Update or Delete operation in a trans ...

  6. Entity Framework 6.0 Tutorials(3):Code-based Configuration

    Code-based Configuration: Entity Framework 6 has introduced code based configuration. Now, you can c ...

  7. Entity Framework 6.0 Tutorials(2):Async query and Save

    Async query and Save: You can take advantage of asynchronous execution of .Net 4.5 with Entity Frame ...

  8. Entity Framework 6.0 Tutorials(8):Custom Code-First Conventions

    Custom Code-First Conventions: Code-First has a set of default behaviors for the models that are ref ...

  9. Entity Framework 6.0 Tutorials(7):DbSet.AddRange & DbSet.RemoveRange

    DbSet.AddRange & DbSet.RemoveRange: DbSet in EF 6 has introduced new methods AddRange & Remo ...

随机推荐

  1. 转:django在生成数据库时常常遇到的问题

    真的很有用! http://blog.csdn.net/pipisorry/article/details/45727309

  2. FastAdmin 学习线路 (2018-09-09 增加 Layer 组件)

    FastAdmin 学习线路 (2018-09-09 增加 Layer 组件) 基础 HTML CSS DIV Javascript 基础 jQuery php 基础 对象 命名空间 Apache 或 ...

  3. merge into报错ORA-00926、ORA-38014

    今天用ibatis写个插入操作,为了兼容修改想使用 merge into语句,以便重复插入时直接 update,具体语句如下: <insert id="wlf"> ME ...

  4. 第13篇 PSR-2代码样式

    这个规范原文如下: 1. Overview Code MUST follow a "coding style guide" PSR [PSR-1]. Code MUST use 4 ...

  5. H5浏览器播放RTMP直播流

    <!DOCTYPE html><html><head><meta charset="UTF-8"><title>Inse ...

  6. 1126 Eulerian Path

    题意:若图是连通图,且所有结点的度均为偶数,则称为Eulerian:若有且仅有两个结点的度为奇数,则称为semi-Eulerian.现给出一个图,要我们判断其是否为Eulerian,semi-Eule ...

  7. php代码优化 -- array_walk 和 foreach, for 的效率的比较

    <?php /** * array_walk 和 foreach, for 的效率的比较. * 我们要测试的是foreach, for, 和 array_walk的效率的问题. */ //产生一 ...

  8. Unity3D Demo

    之前在Unity讨论Q群里总是有不少同学求项目资源和源码神马的,其实这种资源在官网很多,而且都比较规范和专业,很有参考价值,链接:https://www.assetstore.unity3d.com/ ...

  9. linux信号量使用

    #include <pthread.h> #include <semaphore.h> #include <unistd.h> #include <stdio ...

  10. Java微信公众平台开发--番外篇,对GlobalConstants文件的补充

    转自:http://www.cuiyongzhi.com/post/63.html 之前发过一个[微信开发]系列性的文章,也引来了不少朋友观看和点评交流,可能我在写文章时有所疏忽,对部分文件给出的不是 ...