Я добавил колонку к aspnetusers ранее в проекте через модель ApplicationUser, и она прошла нормально. Но теперь позже в проекте, когда я пытаюсь добавить другой проект, я получаю: Номер ошибки: 207, Состояние: 1, Класс: 16 <---. </p>
Модель:
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; }
}
Контекст:
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);
}
}
Целое сообщение, которое я получаю в PMC, слишком длинное, чтобы делиться здесь, но в начале оно говорит что-то с неверным именем столбца:
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'.