This article is a mirror article of machine translation, please click here to jump to the original article.

View: 23763|Reply: 0

[Source] Unique Key constraints for multiple columns in the Entity Framework (Unique Key constr ...

[Copy link]
Posted on 1/28/2019 2:53:21 PM | | |
Unique Key constraints for multiple columns in Entity Framework
I'm using Entity Framework 5.0 Code First;



I want to make

Id FirstColumn SecondColumn
1 1 1 = OK
2 2 1 = OK
3 3 3 = OK
5 3 1 = this OK
4 3 3 = GRRRRR! There is a mistake here
solution

With Entity Framework 6.1, you can now do this:


The second parameter in the property is where you can specify the position of the columns in the index.

MSDN documentation:https://docs.microsoft.com/zh-cn ... otations#IndexMulti





Previous:{ get; } in C#; set; What does it mean and how to use it?
Next:.NET Core File Providers
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com