Issue
This is a barebones application with only one class: AppUser having only (Id, FirstName, LastName, Phone1, Phone2, KnownAs, EmailAddress, Question, Answer, and IsTrialMode.
DataContext is only:
public class DataContext : DbContext
{
public DataContext(DbContextOptions options) : base(options)
{
}
public DbSet<AppUser> Users { get; set; }
}
When I do a dotnet ef migrations add command, the migrations file contains:
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastName = table.Column<string>(type: "nvarchar(max)", nullable: true),
Phone1 = table.Column<string>(type: "nvarchar(max)", nullable: true),
Phone2 = table.Column<string>(type: "nvarchar(max)", nullable: true),
KnownAs = table.Column<string>(type: "nvarchar(max)", nullable: true),
EmailAddress = table.Column<string>(type: "nvarchar(max)", nullable: true),
Question = table.Column<string>(type: "nvarchar(max)", nullable: true),
Answer = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsTrialMode = table.Column<bool>(type: "bit", nullable: false),
UserName = table.Column<string>(type: "nvarchar(max)", nullable: true),
NormalizedUserName = table.Column<string>(type: "nvarchar(max)", nullable: true),
Email = table.Column<string>(type: "nvarchar(max)", nullable: true),
NormalizedEmail = table.Column<string>(type: "nvarchar(max)", nullable: true),
EmailConfirmed = table.Column<bool>(type: "bit", nullable: false),
PasswordHash = table.Column<string>(type: "nvarchar(max)", nullable: true),
SecurityStamp = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(max)", nullable: true),
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
PhoneNumberConfirmed = table.Column<bool>(type: "bit", nullable: false),
TwoFactorEnabled = table.Column<bool>(type: "bit", nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
LockoutEnabled = table.Column<bool>(type: "bit", nullable: false),
AccessFailedCount = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
This is clearly NOT what I was expecting.
What is causing this; how to make it stop?
Thanks in advance. "Chuck"
Solution
From your migration file, the additional properties seem to be the IdentityUser
class default properties.
Be sure your AppUser does not extend IdentityUser
or IdentityUser<T>
class:
public class AppUser
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Phone1 { get; set; }
public string Phone2 { get; set; }
public string KnownAs { get; set; }
public string Question { get; set; }
public string Answer { get; set; }
public string EmailAddress { get; set; }
public bool IsTrialMode { get; set; }
}
Answered By - Rena Answer Checked By - Mary Flores (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.