我已经在前面的项目中通过ApplicationUser模型向aspnetusers添加了一个列,一切正常。但是现在在项目后面,当我尝试添加另一个项目时,我得到了:错误号:207,状态:1,类:16 <---。
模型:
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'.