📜  可为空的唯一约束 ef - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:23.410000             🧑  作者: Mango

代码示例1
// Add unique nullable index 
string indexName = "IX_UQ_UniqueColumn";
string tableName = "dbo.ExampleClasses";
string columnName = "UniqueColumn";

Sql(string.Format(@"
    CREATE UNIQUE NONCLUSTERED INDEX {0}
    ON {1}({2}) 
    WHERE {2} IS NOT NULL;",
    indexName, tableName, columnName));