I have an application that has been running for years (5 at least) and it has been working fine. I have come to update an Entity (Email) which looks like this:

public class Email
{
    public int Id { get; set; }
    public bool Sent { get; set; }
    public string UserId { get; set; }

    [Required, MaxLength(100)] public string From { get; set; }
    [Required, MaxLength(100)] public string To { get; set; }
    [MaxLength(100)] public string Cc { get; set; }
    [MaxLength(100)] public string Bcc { get; set; }
    [Required, MaxLength(100)] public string Subject { get; set; }
    public string Substitutions { get; set; }

    [MaxLength(128)] public string TemplateId { get; set; }
    public string Body { get; set; }

    public DateTime DateCreated { get; set; }
    public DateTime DateUpdated { get; set; }
}

I ran add-migration OptionalSubstitutions to generate a file that I can then use update-database. The issue is, it throws an error:

User_Logins_Target: : Multiplicity is not valid in Role 'User_Logins_Target' in relationship 'User_Logins'. Because the Dependent Role refers to the key properties, the upper bound of the multiplicity of the Dependent Role must be '1'.

I have not touched the User class, it uses AspNet.Identity and looks like this:

public class User : IdentityUser
{
    [Required] [MaxLength(100)] public string FirstName { get; set; }
    [Required] [MaxLength(100)] public string LastName { get; set; }
    [Required] [MaxLength(100)] public string Department { get; set; }
    [MaxLength(4)] public string Master { get; set; }
    public bool Disabled { get; set; }
    [MaxLength(255)] public string ProfileImageUri { get; set; }

    public DateTime DateCreated { get; set; }
    public DateTime? DateModified { get; set; }
    public DateTime LastLoginDate { get; set; }
}

Like I said, I have not changed this class and I don't have control over the UserLogins so I am not sure why I am getting this error...

Has anyone else encountered it? If so, how did you solve it?

0 Answers