首页 > 其他 > 详细

Entity Framework 6.0 Tutorials(10):Index Attribute

时间:2016-07-07 12:44:30      阅读:231      评论:0      收藏:0      [点我收藏+]

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

原文:http://www.cnblogs.com/purplefox2008/p/5649584.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!