将 Asp.Net Core RC1 迁移到 RC2 后的问题

Kri*_*nan 5 asp.net-core

我们已将我们的项目从 Asp.Net 核心 RC1 迁移到 RC2。迁移后,我们在以下位置收到 2 个编译错误。

第一个问题是在startup.cs中,“以下方法或属性之间的调用不明确:”

public void ConfigureServices(IServiceCollection services)
{

...

services.AddIdentity<ApplicationUser, IdentityRole>()
       .AddEntityFrameworkStores<ApplicationDbContext>()
       .AddDefaultTokenProviders();


       ...
}
Run Code Online (Sandbox Code Playgroud)

错误详情:

Error   CS0121  The call is ambiguous between the following methods or properties: 'Microsoft.Extensions.DependencyInjection.IdentityServiceCollectionExtensions.AddIdentity<TUser, TRole>(Microsoft.Extensions.DependencyInjection.IServiceCollection)' and 'Microsoft.Extensions.DependencyInjection.IdentityServiceCollectionExtensions.AddIdentity<TUser, TRole>(Microsoft.Extensions.DependencyInjection.IServiceCollection)'  Firebolt.SecurityService..NETCoreApp,Version=v1.0   C:\Krishnan\RSI\SourceCode\Bluesky Developement\BlueSky Development\Firebolt.Security\src\Firebolt.Security\Startup.cs  58  Active
Run Code Online (Sandbox Code Playgroud)

第二期:

[Microsoft.Data.Entity.Infrastructure.DbContext(typeof(ApplicationDbContext))]
    [Migration("00000000000000_CreateIdentitySchema")]
    partial class CreateIdentitySchema
    {
        protected override void BuildTargetModel(Microsoft.EntityFrameworkCore.ModelBuilder modelBuilder)
        {
     ...
}
Run Code Online (Sandbox Code Playgroud)

错误详情:

 Error  CS0115  'CreateIdentitySchema.BuildTargetModel(ModelBuilder)': no suitable method found to override Firebolt.SecurityService..NETCoreApp,Version=v1.0   C:\Krishnan\RSI\SourceCode\Bluesky Developement\BlueSky Development\Firebolt.Security\src\Firebolt.Security\Migrations\00000000000000_CreateIdentitySchema.Designer.cs  15  Active
Run Code Online (Sandbox Code Playgroud)

这两个问题的解决方法是什么?有任何想法吗

spa*_*pan 12

我在使用 dot net core 2.0 的迁移中也遇到了这个错误。希望这可以帮助某人。

错误 CS0115 'init.BuildTargetModel(ModelBuilder)': 找不到合适的方法来覆盖

在重构之后,我的迁移类被移动到一个新的命名空间。我已经将它们从MyApp.MigrationstoMyApp.Web.Migrations和 dot net 不喜欢那样。

我把他们搬回了那里MyApp.Migrations,他们不再抱怨了。

  • 不完全一样,但给我指出了问题。移动后,.Designer 文件没有获取命名空间更改。更新修复了它 (5认同)
  • 您遇到的问题和我解决的问题是两个部分文件必须位于同一名称空间中。 (5认同)

Kri*_*nan 2

我已经找到了这两个问题的解决方案。我在这里发布它可能对其他人有用

首要问题

错误 CS0121 以下方法或属性之间的调用不明确:“Microsoft.Extensions.DependencyInjection.IdentityServiceCollectionExtensions.AddIdentity<TUser, TRole>(Microsoft.Extensions.DependencyInjection.IServiceCollection)”和“Microsoft.Extensions.DependencyInjection.IdentityServiceCollectionExtensions.AddIdentity<” TUser,TRole>(Microsoft.Extensions.DependencyInjection.IServiceCollection)' Firebolt.SecurityService..NETCoreApp,版本=v1.0

问题出在 Project.json 中的以下 2 个配置条目。我用以下 2 条替换了现有条目,它解决了问题

 "Microsoft.AspNetCore.Identity": "1.0.0-rc2-final",
 "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-rc2-final",
Run Code Online (Sandbox Code Playgroud)

错误CS0115“CreateIdentitySchema.BuildTargetModel(ModelBuilder)”:找不到合适的方法来覆盖Firebolt.SecurityService..NETCoreApp,版本= v1.0

查找/替换所有迁移相关类中现有的 using 命名空间

using Microsoft.Data.Entity with using Microsoft.EntityFrameworkCore
Run Code Online (Sandbox Code Playgroud)