I tried to create unique key constraints for two columns using below code but showing error.
[Index("IX_FirstAndSecond", 1, IsUnique = true)] public int FirstColumn { get; set; }
[Index("IX_FirstAndSecond", 2, IsUnique = true)] public int SecondColumn { get; set; }
Is there any system to create unique key constraints for multiple columns??
6 Answer(s)
-
0
Hi,
Your code seems correct. What error are you getting? If it can not find the Index atrribute, you need to add EntityFramework nuget package to the .Core project.
-
0
Thanks a lot.
Now raising another question,
When using sqlBulkInsert for large data it's getting error if there any redundant data. Is there any solution that sqlBulkInsert will insert all unique data just skipping the row of error.
-
0
Hi,
I think that's not directly related to AspNet Zore. Have you searched web for it?
-
0
Dear,
in new version, what need to use replace of [Index(IsUnique = true)]?
this show error.
Thanks
-
0
Hi,
Index is an attibute defined in EntityFramework, and not related to AspNet Zero. Have you added EntityFramework nuget package to your .Core project and added System.ComponentModel.DataAnnotations.Schema namespace to your code file?
-
0
Hi,
thans its working after install EntityFramework package.
Thanks