Ricardo, unfortunately I do not think it is possible, but through Migrations it is possible to create a contour solution.
After using the -EnableMigration
and add-migration %Migration Name%
commands, open the newly created migration file and edit the following line within the Up
method:
Sql(string.Format(@"CREATE UNIQUE NONCLUSTERED INDEX IXCU_{0}_{1}_notnull
ON {0}({1}) WHERE yourcolumn IS NOT NULL", nomeTabela, nomeColuna);
If there is already an index with the same database name, be sure to add the following line in the Down
method:
DropIndex(nomeTabela, string.Format("IXCU_{0}_{1}_notnull", nomeTabela, nomeColuna));
Now you can run update-database
.