© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
B. L. GormanPractical Entity Framework Core 6https://doi.org/10.1007/978-1-4842-7301-2_5

5. Constraints, Keys, and Relationships

Brian L. Gorman1  
(1)
Jesup, IA, USA
 

In this chapter, you are going to learn about how you can use Data Annotations to further constrain your database structures from code. In addition, you’ll look at how you can easily build out some relationships in your models that translate directly into relationships in the database.

When you’ve finished with this chapter, you’ll have the ability to correctly create entities that not only specify type but have further constraints like primary and secondary keys and limiting the length on strings. ...

Get Practical Entity Framework Core 6: Database Access for Enterprise Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.