ardalis / ardalis/EFCore.Extensions

Value Object Configuration Issue

Open
#2 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
44
Forks
8
PR merge metrics
No merged PRs in 30d

Description

When using the extension method to find configuration files, this error occurs:

```
[16:22:36 INF] Seeding Database...catalogContext
[16:22:36 ERR] The entity type 'ImageBanner' requires a primary key to be defined. If you intended to use a keyless entity type, call 'HasNoKey' in 'OnModelCreating'. For more information on keyless entity types, see https://go.microsoft.com/fwlink/?linkid=2141943.
```

Relevant code from AppDbContext:

```csharp
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);

modelBuilder.ApplyAllConfigurationsFromCurrentAssembly(); // causes problems

// alternately this is built-in to EF Core 2.2
//modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
}

```

Using the built-in `ApplyConfigurationsFromAssembly` version works fine.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the error from AppDbContext.OnModelCreating using ApplyAllConfigurationsFromCurrentAssembly, then inspect that extension and compare its behavior with EF Core's ApplyConfigurationsFromAssembly. Done means the extension no longer produces the ImageBanner primary-key error while the built-in method continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.