Skip to content
Extension methods to make working with EF Core easier.
C#
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/Ardalis.EFCore.Extensions Adding version info Aug 16, 2019
.gitignore Adding fix for current assembly Aug 16, 2019
Ardalis.EFCore.Extensions.sln Added solution items. Aug 16, 2019
LICENSE Initial commit Jul 22, 2019
README.md Adding fix for current assembly Aug 16, 2019
azure-pipelines.yml Set up CI with Azure Pipelines Jul 22, 2019

README.md

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
You can’t perform that action at this time.