Index Attribute:

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

  1. class Student
  2. {
  3. public Student()
  4. {
  5. }
  6.  
  7. public int Student_ID { get; set; }
  8. public string StudentName { get; set; }
  9.  
  10. [Index]
  11. public int RegistrationNumber { get; set; }
  12. }

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.

  1. [Index( "INDEX_REGNUM", IsClustered=true, IsUnique=true )]
  2. 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. UIImage+PYJAnimatedGIF

    UIImage+PYJAnimatedGIF.h: #import <UIKit/UIKit.h> @interface UIImage (PYJAnimatedGIF) + (UIIma ...

  2. iOS10修改电池状态栏的方法

  3. 11.7noip模拟赛

     题解:广义斐波那契数列 矩阵乘法 #include<iostream> #include<cstdio> #include<cstring> #define LL ...

  4. c#学习笔记 VS编辑器常用设置

    1.NET Framework 4.0安装好后目录在哪里? C:\Windows\Microsoft.NET\Framework下面 C#中CLR和IL分别是什么含义? CLR common lang ...

  5. (转)Android强制设置横屏或竖屏

    全屏 在Activity的onCreate方法中的setContentView(myview)调用之前添加下面代码 requestWindowFeature(Window.FEATURE_NO_TIT ...

  6. plsql无法连接64位oracle数据库的解决方法

    今儿个重装了个系统,win8 64位.接着装了个64位的oracle11g,oracle11g下载页面:http://www.oracle.com/technetwork/database/enter ...

  7. oracle11g,安装失败,提示找不到文件,win7 64位下报错

    提示: 未找到文件 E:\app\Administrator\product\11.2.0\dbhome_5\owb\external\oc4j_applications\applications\W ...

  8. 安装ruby-pg报错解决

    ruby用pgsql做orm的时候,需要安装ruby-pg库,默认编译安装会提示缺少xx头文件 max下,我用的傻瓜式pgsql.app gem install pg -- --with-pg-con ...

  9. nextSibling VS nextElementSibling

    2. nextSibling vs nextElementSibling { //FF { 在Firefox中,link2的nextSibling并不是link3,因为两者之间有一个换行符. 这被认为 ...

  10. (转)Oracle 临时表用法

    本文转载自:http://www.iteye.com/topic/371390 ORACLE的临时表在应用系统中有很大的作用,它可以让用户只能够操作各自的数据中而互不干扰,不用担心会破坏或影响其他SE ...