Note that there are some explanatory texts on larger screens.

plurals
  1. POEntity Framework Code-First Issues (SimpleMembership UserProfile table)
    primarykey
    data
    text
    <p>If you've used ASP.NET MVC 4 you'll notice that the default for an Internet Application is to use the SimpleMembership provider, this is all well and good and works fine.</p> <p>The issue comes with the default database generation, they have a POCO for <code>UserProfile</code> defined like so:</p> <pre><code>[Table("UserProfile")] public class UserProfile { [Key] [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public int UserId { get; set; } public string UserName { get; set; } } </code></pre> <p>.. which is then generated like this:</p> <pre><code>using (var context = new UsersContext()) { if (!context.Database.Exists()) { // Create the SimpleMembership database without Entity Framework migration schema ((IObjectContextAdapter)context).ObjectContext.CreateDatabase(); } } </code></pre> <p>This works fine, the database is generated just fine and works without issue. However, if I am to change the POCO like this and delete the database:</p> <pre><code>[Table("UserProfile")] public class UserProfile { [Key] [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public int UserId { get; set; } public string EmailAddress { get; set; } public string FirstName { get; set; } public string Surname { get; set; } public string Country { get; set; } public string CompanyName { get; set; } } </code></pre> <p>Only the first 2 columns are generated, <code>UserId</code> and <code>EmailAddress</code>. It works just fine code-wise (talking login/registration), but obviously none of my other user data is stored.</p> <p>Am I missing something here? Surely it should generate the database based off the whole <code>UserProfile</code> object.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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