Configuration

What is it about?

Configurations enable you to override Entity Framework Core's default behaviour (conventions) in respect to mapping entities and their properties and relationships to a relational database

Examples

Create Configuration Class

frontier dotnet add configuration [name-of-configuration]

Generates NameOfConfiguration.cs

using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using NameOfProject.Domain.Entities; namespace NameOfProject.Persistence.Configurations { public class NameOfConfigurationConfiguration : IEntityTypeConfiguration<Faq> { public void Configure(EntityTypeBuilder<Faq> builder) { builder.Property(e => e.Property1) .HasColumnName("Property1") builder.Property(e => e.Property2) .IsRequired(); } } }

Description: This command generates a class configuration based of the name used in the command. The file will be located at projectName/src/ProjectNameApi.Persistence/NameOfConfiguration.cs. The file can then be modified to suit user's desired table.


Table of Contents