Reputation: 7
I am new to Entity Framework. I want to make it Database as a separate Entity In project. So I started my project with as Class Library project. Starting with Login so class created for it with inherit IdentityUser.
public class ApplicationUser : IdentityUser
{
[Required]
[MaxLength(200)]
public string FirstName { get; set; }
[Required]
[MaxLength(500)]
public string LastName { get; set; }
}
Now I want to create database , I have added key in App.Config.
public class AppDBContext : DbContext
{
public AppDBContext():base("AppDBConnectionString")
{
}
}
Any Package Manager command to create database for first time ? Update-Database didnt work.
Upvotes: 0
Views: 221
Reputation: 2971
Ok, to summarize, update your class to include a key:
public class ApplicationUser : IdentityUser
{
[Key]
public int ApplicationUserId { get; set; }
[Required]
[MaxLength(200)]
public string FirstName { get; set; }
[Required]
[MaxLength(500)]
public string LastName { get; set; }
}
And update your DbSet in your AppDbContext to:
DbSet<ApplicationUser> ApplicationUsers { get; set; }
Upvotes: 1