DbMigration.CreateIndex 方法 (String, String, Boolean, String, Boolean, Object)

[本页针对的是实体框架版本 6。最新版本以“实体框架”NuGet 包的形式提供。有关实体框架的更多信息,请参见 msdn.com/data/ef。]

添加在单列上创建索引的操作。 实体框架迁移 API 未被设计为接受不可信源(例如应用程序的最终用户)提供的输入。 如果接受来自此类源的输入,则应该首先对其进行验证,然后传递给这些 API,以便防止 SQL 注入攻击之类的威胁。

命名空间:  System.Data.Entity.Migrations
程序集:  EntityFramework(在 EntityFramework.dll 中)

语法

声明
<SuppressMessageAttribute("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")> _
Protected Friend Sub CreateIndex ( _
    table As String, _
    column As String, _
    unique As Boolean, _
    name As String, _
    clustered As Boolean, _
    anonymousArguments As Object _
)
用法
Dim table As String 
Dim column As String 
Dim unique As Boolean 
Dim name As String 
Dim clustered As Boolean 
Dim anonymousArguments As Object 

Me.CreateIndex(table, column, unique, _
    name, clustered, anonymousArguments)
[SuppressMessageAttribute("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
protected internal void CreateIndex(
    string table,
    string column,
    bool unique,
    string name,
    bool clustered,
    Object anonymousArguments
)
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1026:DefaultParametersShouldNotBeUsed")]
protected public:
void CreateIndex(
    String^ table, 
    String^ column, 
    bool unique, 
    String^ name, 
    bool clustered, 
    Object^ anonymousArguments
)
[<SuppressMessageAttribute("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")>]
member CreateIndex : 
        table:string * 
        column:string * 
        unique:bool * 
        name:string * 
        clustered:bool * 
        anonymousArguments:Object -> unit
function CreateIndex(
    table : String, 
    column : String, 
    unique : boolean, 
    name : String, 
    clustered : boolean, 
    anonymousArguments : Object
)

参数

  • table
    类型:System.String
    要在其上创建索引的表的名称。 架构名称是可选的,如果未指定架构,则将假定 dbo。
  • column
    类型:System.String
    要在其上创建索引的列的名称。
  • unique
    类型:System.Boolean
    指示此索引是否是唯一索引的值。 如果未提供任何值,则将创建非唯一索引。
  • name
    类型:System.String
    用于数据库中的索引的名称。 如果未提供任何值,则将生成唯一名称。
  • clustered
    类型:System.Boolean
    指示此索引是否是聚集索引的值。
  • anonymousArguments
    类型:System.Object
    提供程序可能会处理的其他参数。 使用匿名类型语法指定参数,例如“ new { SampleArgument = "MyValue" }”。

请参阅

参考

DbMigration 类

CreateIndex 重载

System.Data.Entity.Migrations 命名空间