Skip to content

Extension methods to make working with EF Core easier.

License

Notifications You must be signed in to change notification settings

navidfaridi/EFCore.Extensions

 
 

Repository files navigation

NuGetNuGet Build Status

EFCore.Extensions

Extension methods to make working with EF Core easier.

  • ApplyAllConfigurationsFromCurrentAssembly

Sample Usage

using Ardalis.EFCore.Extensions;
using Microsoft.EntityFrameworkCore

namespace YourNamespace
{
    public class AppDbContext : DbContext
    {
        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);
        
            // ApplyConfiguration calls must follow base.OnModelCreating()
            builder.ApplyAllConfigurationsFromCurrentAssembly();

			// Apply configurations in a different assembly - just reference a type in that assembly
			modelBuilder.ApplyAllConfigurationsFromCurrentAssembly(typeof(ToDoItem).Assembly);
        }
    }
}

To Test, Run Migrations

A sample migration script to add migrations to a Clean Architecture solution template is shown here (run from the solution root):

dotnet ef migrations add Initial -p .\src\CleanArchitecture.Infrastructure\CleanArchitecture.Infrastructure.csproj -s .\src\CleanArchitecture.Web\CleanArchitecture.Web.csproj -o Data/Migrations

About

Extension methods to make working with EF Core easier.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%