Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDávid Molnár
27,081 PointsEntity Framework: How to give Id values uint type?
Just started learning Entity Framework and as I see all my Id values must be defined as int otherwise it's not working as intended. Might I change somehow the "required" int type to a larger or unsigned type?
1 Answer
Steven Parker
231,248 PointsWhy would you want to change the ID type? Using "int" should be appropriate for ID's no matter what other data is carried in the record.
Dávid Molnár
27,081 PointsDávid Molnár
27,081 PointsI just had the idea: "Why would I have a type that can be negative for Id, can I change that?"
Steven Parker
231,248 PointsSteven Parker
231,248 PointsTypically, you want the type to match what is used in the database, and "int" is most likely to be it. Also, the sign is unimportant, ID's only have to be unique, they aren't compared by magnitude. And whether or not they are allowed, negative values are not likely to be assigned as a record ID.