Ada*_*dam 5 entity-framework-core asp.net-core
我刚刚开始迁移到 SQL 数据库并遇到了抛出 MissingMethodException 的问题。这是引发错误的配置类:
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Project.Core.Entities.Users;
namespace Project.Persistance.Configuration.Users
{
public class UserClaimTypeConfiguration : IEntityTypeConfiguration<UserClaimType>
{
public void Configure(EntityTypeBuilder<UserClaimType> builder)
{
builder.HasKey(entity => entity.Id);
builder.Property(entity => entity.Name)
.IsRequired()
.HasMaxLength(30);
builder.HasIndex(entity => entity.Name);
builder.Property(entity => entity.Description)
.IsRequired(false)
.HasMaxLength(100);
builder.Ignore(entity => entity.ValueType);
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我在控制台中遇到的错误:
PM> add-migration user
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MissingMethodException: Method not found: 'Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder`1.HasIndex(System.Linq.Expressions.Expression`1<System.Func`2<!0,System.Object>>)'.
at Project.Persistance.Configuration.Users.UserClaimTypeConfiguration.Configure(EntityTypeBuilder`1 builder)
at Microsoft.EntityFrameworkCore.ModelBuilder.ApplyConfiguration[TEntity](IEntityTypeConfiguration`1 configuration)
Run Code Online (Sandbox Code Playgroud)
我已经尝试过“Goggle”和 Microsoft 文档,但似乎找不到对此问题的任何参考 - 所以它一定是我的设置。就是想不通是什么原因造成的!
| 归档时间: |
|
| 查看次数: |
7767 次 |
| 最近记录: |