O'Reilly logo

Entity Framework Core Cookbook - Second Edition by Ricardo Peres

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

Retrieving entity metadata

When you create an Entity Framework context, you map a domain model to a data store. Specifically, in the case of relational databases, you assign the following:

  • Classes to tables
  • Properties to columns
  • References to foreign keys

Of course, in normal usage, you normally don't need to worry about these mappings; you just query the POCO domain model and that's it. But if you need to write SQL for more advanced queries, you are left with two options:

  • You know exactly the database names of all the tables and columns (keep in mind that the class Person can be mapped to, say, PERSON, PEOPLE, PERSON_DETAIL, PERSON_DETAILS, and so on)
  • You obtain this information dynamically at runtime

If you want to be safe, you will stick to the second ...

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