Creating Migration Error

0

I am creating a user registry in C #, but when I include the domain layer and I am going to create the migration, the error below is happening. I could not identify what is happening.

"No suitable builder found for entity type 'User'. The following parameters could not be bound to properties of the entity: 'cellPhone', 'address'."

namespace AgendaWeb.Domain.Users
{
public class User
{
    public int Id { get; private set; }
    public string UserName { get; private set; }
    public string FullName { get; private set; }
    public string Cpf { get; private set; }
    public string Email { get; private set; }
    public string Phone { get; private set; }
    public string Cellphone { get; private set; }
    public string PhotoUrl { get; private set; }
    public string Password { get; private set; }
    public DateTime RegistrationDate { get; private set; }
    public DateTime? DateOfBirth { get; private set; }
    public string ProfileType { get; private set; }

    public Address Address { get; private set; }

    public User(string userName, string fullName, string cpf, string email, string phone, string cellPhone, string photoUrl, string password, DateTime registrationDate, DateTime? dateOfBirth, string profileType, Address address )
    {
        ValidateValues(userName, fullName, cpf, email, phone, cellPhone, photoUrl, password, registrationDate, dateOfBirth, profileType, address);
        SetProperties(userName, fullName, cpf, email, phone, cellPhone, photoUrl, password, registrationDate, dateOfBirth, profileType, address);

    }

    public void Update(string userName, string fullName, string cpf, string email, string phone, string cellPhone, string photoUrl, string password, DateTime registrationDate, DateTime? dateOfBirth, string profileType, Address address)
    {
        ValidateValues(userName, fullName, cpf, email, phone, cellPhone, photoUrl, password, registrationDate, dateOfBirth, profileType, address);
        SetProperties(userName, fullName, cpf, email, phone, cellPhone, photoUrl, password, registrationDate, dateOfBirth, profileType, address);

    }

    private void SetProperties(string userName, string fullName, string cpf, string email, string phone, string cellPhone, string photoUrl, string password, DateTime registrationDate, DateTime? dateOfBirth, string profileType, Address address)
    {
        UserName = userName;
        FullName = fullName;
        Cpf = cpf;
        Email = email;
        Phone = phone;
        Cellphone = cellPhone;
        PhotoUrl = photoUrl;
        Password = password;
        RegistrationDate = registrationDate;
        DateOfBirth = dateOfBirth;
        ProfileType = profileType;
        Address = address;
    }

    private static void ValidateValues(string userName, string fullName, string cpf, string email, string phone, string cellPhone, string photoUrl, string password, DateTime registrationDate, DateTime? dateOfBirth, string profileType, Address address)
    {
        DomainException.When(string.IsNullOrEmpty(userName), "O campo nome é obrigatório!");
    }
}

}

    
asked by anonymous 06.07.2018 / 03:18

1 answer

1

If you are using the Entity Framework in .NET Full, you must have a protected parameterless constructor.

If you are using the Entity Framework Core, you can have parameterized constructors, but you can not use complex types as parameters, so only primitive types can be used in the constructor.

In EF Core, you have two outputs: create a protected constructor without parameters, take out the complex types of the existing constructor.

Source: Entity Types with Builders - EF Core

    
06.07.2018 / 03:23