EntityFramework-Reverse-POCO-Code-First-Generator icon indicating copy to clipboard operation
EntityFramework-Reverse-POCO-Code-First-Generator copied to clipboard

Unique Filtered Index issue

Open thomasbach-dk opened this issue 5 years ago • 1 comments

If you have an Unique Index on a table:

CREATE UNIQUE INDEX [NameOfTheIndex] ON [TableName] ([Identifier])

It will be handled in the POCO's ModelConfiguration like:

builder.HasAlternateKey(x => x.Identifier).HasName("NameOfTheIndex");

Which is great, if it´s just a plain Unique Index. But if it´s a Filtered Index with uniqueness like:

CREATE UNIQUE INDEX [NameOfIndex] ON [TableName] ([Identifier]) WHERE [IsPrimary] = 1

You´ll get a Runtime Error if you insert more than one element with the same identifier, which is not what I´m trying to achieve.

Is it possible to exclude Unique Indexes with filters from being handled at all?

Best regards, Thomas screenshot

thomasbach-dk avatar Feb 19 '20 12:02 thomasbach-dk

Thank @thbaan Grab the latest code. I removed has alternate key as you can't edit the field marked with that as entity framework makes it read only.

sjh37 avatar Feb 19 '20 18:02 sjh37