© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
7 replies
altyn

Issues with EFCore

Hello everyone, I am trying to use ApplyConfigurationsFromAssembly but it seems to not be finding any configurations

        modelBuilder.ApplyConfigurationsFromAssembly(typeof(UserConfiguration).Assembly);
        modelBuilder.ApplyConfigurationsFromAssembly(typeof(UserConfiguration).Assembly);


Instead, I have to apply configurations like this
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        // Call the base OnModelCreating
        base.OnModelCreating(modelBuilder);
        
        new PermissionConfiguration().Configure(modelBuilder.Entity<Permission>());
        new RoleConfiguration().Configure(modelBuilder.Entity<Role>());
        new UserConfiguration().Configure(modelBuilder.Entity<User>());
    }
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        // Call the base OnModelCreating
        base.OnModelCreating(modelBuilder);
        
        new PermissionConfiguration().Configure(modelBuilder.Entity<Permission>());
        new RoleConfiguration().Configure(modelBuilder.Entity<Role>());
        new UserConfiguration().Configure(modelBuilder.Entity<User>());
    }


and to apply them in correct order or migrations won't work, I am not sure what could be causing this issue, I have a clean architecture solution split into multiple projects. Could anyone point me to the right direction?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Efcore - Database issues (Sqlite)
C#CC# / help
16mo ago
✅ EFCore issues when removing an entity,
C#CC# / help
2y ago
✅ EFCore Tables with inharitance
C#CC# / help
3mo ago
Using MongoDB EFCore with HotChocolate
C#CC# / help
9mo ago