Note that there are some explanatory texts on larger screens.

plurals
  1. PONew fields not added in the database Code first
    text
    copied!<p>I was following <a href="http://blog.longle.net/2012/09/25/seeding-users-and-roles-with-mvc4-simplemembershipprovider-simpleroleprovider-ef5-codefirst-and-custom-user-properties" rel="nofollow">this</a> tutorial which is about moving the <code>SimpleMembershipProvider</code> to your own database with custom fields in the userprofile table. I've added some new fields in the code:</p> <pre><code>[Table("UserProfile")] public class UserProfile { [Key] [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public int UserId { get; set; } public string UserName { get; set; } public string Mobile { get; set; } public string FirstName { get; set; } public string LastName { get; set; } } </code></pre> <p>Then I run the Add-Migration command. And it generates a ######.cs file that looks like this:</p> <pre><code>namespace MVC4SimpleMembershipCodeFirstSeedingEF5.Migrations { using System; using System.Data.Entity.Migrations; public partial class test : DbMigration { public override void Up() { } public override void Down() { } } } </code></pre> <p>The up() and Down() methods have an empty body. Somehow it's not detecting the new changes (added FirstName and LastName fields) i have made.</p> <p>What am I missing here?</p> <p><strong>EDIT:</strong></p> <p>I added the same fields to another table i have created, and that table did get updated in the database.</p> <p>This is what Add-Migration produced:</p> <pre><code>namespace MVC4SimpleMembershipCodeFirstSeedingEF5.Migrations { using System; using System.Data.Entity.Migrations; public partial class test : DbMigration { public override void Up() { AddColumn("dbo.TestTabel", "FirstName", c =&gt; c.String()); AddColumn("dbo.TestTabel", "LastName", c =&gt; c.String()); } public override void Down() { DropColumn("dbo.TestTabel", "LastName"); DropColumn("dbo.TestTabel", "FirstName"); } } } </code></pre> <p>So the problem has been narrowed down to the userprofile table. Whats so special about this table that it can't be altered?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload