O'Reilly logo

ASP.NET Core Essentials by Shahed Chowdhuri

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Code First approach to database design and relationships

So what exactly is a Code First approach? It is exactly what it sounds like. You can model your database objects as entity classes in your code. To establish relationships between those objects, you can define a class to include other classes as member variables. If you already have an existing database, you can create an entity model in your code to represent some (or all) of your database objects.

From our Patient Records example from Chapter 3 , Understanding MVC, we already have a model class that represents a human. In this chapter, we will add a RobotDoctor class to our project to build a computerized system for a futuristic hospital with robot doctors. Then, we will establish a relationship ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required