Trying to add a column to aspnetusers but getting error 207 when adding migration

1

I've added a column to aspnetusers earlier in the project via the ApplicationUser model and it went fine. But now later in the project when i try to add another project i get: Error Number:207,State:1,Class:16<---.

The model:

public class ApplicationUser : IdentityUser
{   //Added before
    public int Credits { get; set; }
    //What i wanna add now
    public DateTime TimeofCreditDeposit { get; set; }

    public IList<Bet> Bets { get; set; }
}

Context:

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
        : base(options)
    {
    }

    public virtual DbSet<Match> Match { get; set; }
    public virtual DbSet<Bet> Bet { get; set; }
    protected override void OnModelCreating(ModelBuilder builder)
    {
        base.OnModelCreating(builder);

        builder.Entity<Match>()
            .HasMany(b => b.Bets)
            .WithOne(m => m.Match);

        builder.Entity<ApplicationUser>()
            .HasMany(b => b.Bets)
            .WithOne(u => u.User);


    }
}

The whole message i get in the PMC is too long to share here but in the beggining it says something with invalid column name:

Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
  User profile is available. Using 
'C:\Users\Andreas\AppData\Local\ASP.NET\DataProtection-Keys' as key 
 repository 
  and Windows DPAPI to encrypt keys at rest.
  Microsoft.EntityFrameworkCore.Infrastructure[10403]
  Entity Framework Core 2.0.3-rtm-10026 initialized 'ApplicationDbContext' 
  using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: 
  None
  Microsoft.EntityFrameworkCore.Database.Command[20101]
  Executed DbCommand (409ms) [Parameters=[@__normalizedName_0='?' (Size = 
  256)], CommandType='Text', CommandTimeout='30']
  SELECT TOP(1) [r].[Id], [r].[ConcurrencyStamp], [r].[Name], [r]. 
  [NormalizedName]
  FROM [AspNetRoles] AS [r]
  WHERE [r].[NormalizedName] = @__normalizedName_0
  fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
  Failed executing DbCommand (2ms) [Parameters=[@__normalizedEmail_0='?' 
  (Size = 256)], CommandType='Text', CommandTimeout='30']
  SELECT TOP(1) [u].[Id], [u].[AccessFailedCount], [u].[ConcurrencyStamp], 
   [u].[Credits], [u].[Email], [u].[EmailConfirmed], [u].[LockoutEnabled], 
   [u]. 
   [LockoutEnd], [u].[NormalizedEmail], [u].[NormalizedUserName], [u]. 
   [PasswordHash], [u].[PhoneNumber], [u].[PhoneNumberConfirmed], [u]. 
   [SecurityStamp], [u].[TimeOfCreditDeposit], [u].[TwoFactorEnabled], [u]. 
   [UserName]
  FROM [AspNetUsers] AS [u]
  WHERE [u].[NormalizedEmail] = @__normalizedEmail_0
  System.Data.SqlClient.SqlException (0x80131904): Invalid column name 
 'TimeOfCreditDeposit'.
c#
entity-framework
migration
entity-framework-core
asked on Stack Overflow Sep 10, 2018 by aneko5

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0