ASP.NET MVC4 - Error When Customize Default Accounts Models & Controller

LabRat

New Member
I am in the begining of making a simple website using ASP.NET MVC4 CodeFirst Approach. The web site is built around users who are able to register, make posts etc. The existing \[code\]UserProfile\[/code\] class was modified for the accommodation other fields (ex: FirstName, LastName etc).When I ran the website I got a similar error:\[code\]Invalid column name 'FirstName'.Invalid column name 'LastName'.Invalid column name 'Phone'.\[/code\]I red that this is because the Database is not updated as the model is updated. So I set the following on the \[code\]Application_Start()\[/code\] in \[code\]Global.asax\[/code\] with the intention of droppnng the database always (at least until I get the hang of it). \[code\]protected void Application_Start() { Database.SetInitializer(new DropCreateDatabaseAlways<UsersContext>()); //Other default generated stuff below... }\[/code\]I also tryed the \[code\]DropCreateDatabaseIfModelChanges\[/code\], but both methods didn't drop the database.Isn't this possible? Why is it? Am I doing some thing wrong?I believe it would be possible to store the info in a different table and link it to this, but I prefer to keep it in one table.Also is it a bad idea to add \[code\]UserProfiles\[/code\] to the websites context (lets say: \[code\]DatabaseContext\[/code\] (which has other entities like Posts, Comments etc) and change the \[code\]AccountsController\[/code\] to use \[code\]DatabaseContext\[/code\] instead of \[code\]UsersContext\[/code\]?Thanks in advance.
 
Back
Top