0

I would like to know how I can add more properties to users in my website. I am using the default user template that is made with a MVC project. I tried using the answer to this post, but I keep getting:

The model backing the 'ApplicationDbContext' context has changed since the database was created

I believe I am missing something that isn't written in that post, can anyone point me to what I need to do?
Thanks.

Community
  • 1
  • 1
master2080
  • 366
  • 3
  • 15
  • Your ApplicationDbContext inherits from IdentityContext? You have the correct project selected in console window? – Steve Greene Sep 10 '16 at 13:53
  • Yes, ApplicationDbContext inherits from IdentityContext. I did not modify the default template that comes with the project on creation. I only added a property to the ApplicationUser class as instructed in the post I linked. – master2080 Sep 10 '16 at 14:13
  • @master2080 Try deleting the record created in your _MigrationHistory table. – Shawn Yan Sep 13 '16 at 01:33

2 Answers2

1

You have to migrate and update your DB after changing default User model in Identity. Try with that.

Dejan Dimčić
  • 294
  • 1
  • 3
  • 9
  • I did, but there were no changes. Just adding a property to the ApplicationUser doesn't seem to do anything to a migration. – master2080 Sep 10 '16 at 12:26
  • After changing User properties, you should migrate that user to update db with that properties. Did you enabled migrations? Something like this: 1. Enable-Migrations 2. Add property 3. Add-Migration “YouMigrationName” 4. Update-Database – Dejan Dimčić Sep 10 '16 at 12:37
  • Yes, I did enable migrations and know how to use them(on some level), but adding the property doesn't make a new migration have any changes.(I did try to update regardless, but the property is not added to the table). – master2080 Sep 10 '16 at 12:47
0

I have figured out the answer. The default user identity model comes with it's own context.
Everywhere I looked, people were always creating an additional context and I thought they both worked together just fine.
Apparently You need to work with each one separately(add migrations to each, and update database with each).

master2080
  • 366
  • 3
  • 15