Foreign key Identity EF

0

I have the following class of UserData and I want to use the User ID generated in Identity EF as foreign key. How do I pull this data, which I'm doing with Migration.

namespace AgendaWeb.Domain.Users
{
    public class UserData
    {           
        public string FullName { get; private set; }
        public string Cpf { get; private set; } 
        public string PhotoUrl { get; private set; }
        public DateTime RegistrationDate { get; private set; }
        public DateTime? DateOfBirth { get; private set; }
        public virtual Address Address { get; private set; }
        public virtual ApplicationUser User { get; private set; }



        private UserData() { }


        public UserData(string fullName, string cpf, string photoUrl, DateTime registrationDate, DateTime? dateOfBirth, Address address, ApplicationUser user)
        {
            ValidateValues(fullName, cpf, photoUrl,registrationDate, dateOfBirth, address, user);
            SetProperties(fullName, cpf, photoUrl, registrationDate, dateOfBirth, address, user);

        }

        public void Update(string fullName, string cpf, string photoUrl, DateTime registrationDate, DateTime? dateOfBirth, Address address, ApplicationUser user)
        {
            ValidateValues(fullName, cpf, photoUrl, registrationDate, dateOfBirth, address, user);
            SetProperties(fullName, cpf, photoUrl, registrationDate, dateOfBirth, address, user);

        }

        private void SetProperties(string fullName, string cpf, string photoUrl, DateTime registrationDate, DateTime? dateOfBirth, Address address, ApplicationUser user)
        {            
            FullName = fullName;
            Cpf = cpf;            
            PhotoUrl = photoUrl;            
            RegistrationDate = registrationDate;
            DateOfBirth = dateOfBirth;            
            Address = address;
            User = user;

        }

        private static void ValidateValues(string fullName, string cpf, string photoUrl, DateTime registrationDate, DateTime? dateOfBirth, Address address, ApplicationUser user)
        {
            //DomainException.When(string.IsNullOrEmpty(fullName), "O campo nome é obrigatório!");

        }
    }
}
    
asked by anonymous 12.08.2018 / 21:59

0 answers