Entity Framework Core

HasKey Method in EF Core

HasKey is a Fluent API method, which allows us to configure the primary key & composite primary of an entity in EF Core. This tutorial shows you how to use if in EF Core.

InverseProperty Attribute in EF Core

The InverseProperty informs the EF Core, which navigational property it relates to on the other end of the relationship. The default convention in EF Core correctly identifies only if there is a single relation between two entities. But in the case of multiple relationships, it fails to correctly identify them. In such cases, we use the InverseProperty to help the EF core correctly identify the relationship.

Required Attribute in EF Core

Data Annotation Required attribute is used for generating NOT NULL columns. Entity framework Code First will create a NOT NULL column if it detects a property having Required attribute.

Data Annotations NotMapped Attribute in EF Core

Apply the NotMapped attribute on those properties, which you do not want to include in your database table. This attribute usually used in the case of calculated fields like Age, Amount, etc. This attribute is available both in Entity Framework & Entity Framework Core

StringLength Attribute in EF Core

The StringLength Attribute Allows us to specify the size of the column. This attribute is available in the System.ComponentModel.DataAnnotations. The attribute works both in entity framework & Entity Framework core.

Scroll to Top