我通过Identity Framework和Core .Net 2.2不断收到此错误:
InvalidOperationException: The entity type 'IdentityUserLogin'
requires a primary key to be defined.
我查看了其他答案并尝试了建议,但它们仅适用于早期版本。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Ca.Models;
namespace Ca.Areas.Identity.Data
{
public class RMISContext : IdentityDbContext<IdentityUser>
{
private object modelBuilder;
public RMISContext(DbContextOptions<RMISContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
// Customize the ASP.NET Identity model and
override the defaults if needed.
// For example, you can rename the ASP.NET Identity table
names and more.
// Add your customizations after calling base.OnModelCreating
(builder);
}
}
}
我希望我能够注册为新用户,但是我收到了前面显示的错误消息。非常感谢您的协助。