Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ardalis/efcore.extensions
Extension methods to make working with EF Core easier.
https://github.com/ardalis/efcore.extensions
Last synced: 3 days ago
JSON representation
Extension methods to make working with EF Core easier.
- Host: GitHub
- URL: https://github.com/ardalis/efcore.extensions
- Owner: ardalis
- License: mit
- Created: 2019-07-22T17:47:28.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-11-24T09:52:48.000Z (12 months ago)
- Last Synced: 2024-11-05T05:06:59.470Z (4 days ago)
- Language: C#
- Size: 24.4 KB
- Stars: 42
- Watchers: 2
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![NuGet](https://img.shields.io/nuget/v/Ardalis.EFCore.Extensions.svg)](https://www.nuget.org/packages/Ardalis.EFCore.Extensions)[![NuGet](https://img.shields.io/nuget/dt/Ardalis.EFCore.Extensions.svg)](https://www.nuget.org/packages/Ardalis.EFCore.Extensions)
[![Build Status](https://dev.azure.com/ardalis/EFCore.Extensions/_apis/build/status/ardalis.EFCore.Extensions?branchName=master)](https://dev.azure.com/ardalis/EFCore.Extensions/_build/latest?definitionId=7&branchName=master)# EFCore.Extensions
Extension methods to make working with EF Core easier.
- ApplyAllConfigurationsFromCurrentAssembly
## Sample Usage
```
using Ardalis.EFCore.Extensions;
using Microsoft.EntityFrameworkCorenamespace 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](https://github.com/ardalis/CleanArchitecture) 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
```