Data Annotations

Data Annotations Key Attribute
Entity Framework Core

Data Annotations Key Attribute in EF Core

The Key Attribute or Primary key attribute maps the property as the primary key column in the database. This attribute is applicable to both Entity Framework & Entity Framework Core. In Entity Framework, we can use it to create Composite Primary key, while in EF Core it is not supported.

Entity Framework Core

Relationships & Navigation Properties in EF Core

In relational databases, it is a healthy practice to divide the data between related tables. For Example, the employee working in a particular department. We do not store both the information in the same table but divide them into Employee & Department table. When we divide tables, we also need to specify the relationships between them. For example, if you are looking for an employee working in a particular department, then you need to specify the relationship between employees and the department table. The relationship between these tables is defined using the foreign keys. We then use these relationships to query the database to get the meaningful data.

Scroll to Top