i have a existing table with a primary key over 3 columns (1 varchar and 2 integer).
How can i tell the entity framework to use this “key”.
Is it possible using the modelBuilder, attributes or is there another way ?
thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In fluent api you must use anonymous type:
Other way is using data annotations:
In both scenarios order of columns is important. Once you try to use
DbSet<YourType>.Findyou will have to supply keys in the same order. EF also uses order internally.