Skip to content

Value Object Configuration Issue #2

@ardalis

Description

@ardalis

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:

        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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions