Migration Issue with ASP.NET Core 2.2 “cannot be marked as nullable/optional because it has been included in a key”

  • Thread starter Thread starter eng teong
  • Start date Start date
E

eng teong

Guest
I have the issue after I type the following command with ASP.NET Core 2.2:

dotnet ef migrations add AddLoginLogoutTime --context xxxContext

and get the following error for the IdentityServer 4

The property 'Id' on entity type 'Microsoft.AspNetCore.Identity.IdentityRole' cannot be marked as nullable/optional because it has been included in a key {'Id'}.

namespace Community.Data.Entities.Users
{
// Add profile data for application users by adding properties to the ApplicationUser class
public class ApplicationUser : IdentityUser
{
public string FullName { get; set; }

public long CompanyId { get; set; }

public long? BeforeSpyingOriginalCompanyId { get; set; }

public bool IsResetPasswordUponLoginNeeded { get; set; }

public bool IsWelcomingFromTraditionalWebsiteNeeded { get; set; }

public bool Status { get; set; } = true;

public bool IsSubscribeWhatsAppMessage { get; set; } = true;

public DateTime CreatedAt { get; set; } = DateTime.Now;

[MaxLength(50)]
public string VerificationCode { get; set; }

public DateTime VerificationCodeExpiryDate { get; set; } = DateTime.Today.ToSqlDefaultDateTime();

public DateTime LoginTime { get; set; } = DateTime.Now;

public DateTime LogoutTime { get; set; } = DateTime.Now;
}
}
Anyone facing this issue and how to solve the error?


I am newbie in enterprise as developer.

Continue reading...
 
Back
Top