No suitable constructor found for entity type '<Entity>'. RRS feed

  • Question

  • Hi guys, first time posting here.

    I've been trying to play with new EF Core 2.1. 

    I created my entities following the DDD concept, so I have used many Value Objects on my Aggregate. But when I try to run my first migration, I receive the following error:

    No suitable constructor found for entity type 'User'. The following parameters could not be bound to properties of the entity: 'street', 'number', 'zip', 'block', 'cityName', 'state', 'addressComplement'.

    My User class has 3 constructors. A private parameterless (which I thought EF would use), one with some parameters to respect the entity's invariants and the last one with a "full" parameters to fill all entity's properties.

    User class has two Value Objects...FullName (string firstname, string surname) and Address(string street, int number, string zip, string block, string cityName, string state, string addressComplement).

    The Address Value Object has a City Value Object inside of it and receives cityName and state - which is passed since User ctor.

    I forgot to add the onModelCreating...

    It is as follows:

    modelBuilder.Entity<Domain.UsuarioContext.User>(u =>
                    u.HasKey(e => e.Id);
                    u.Property(e => e.Profile);
                    u.Property(e => e.Password);
                    u.Property(e => e.Birth);
                    u.Property(e => e.Email);
                    u.OwnsOne(e => e.Name);
                    u.OwnsOne(b => b.Address, e =>
                        e.OwnsOne(c => c.City);


    Tuesday, March 13, 2018 12:52 AM

All replies

  • Hi Rodrigo GS Silva,

    Since your entity framework core 2.1 is not released, I would suggest that you could post your issue on Github for support.


    In addition, please try smitpatel's solution in following thread, which use recreate database and check if it works for you.


    Best regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 13, 2018 7:30 AM