Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issues after migration of Asp.Net Core RC1 to RC2

Tags:

asp.net-core

We have migrated our project from Asp.Net core RC1 to RC2. We are getting 2 compilation errors in the following places after the migrations.

First Issue is in the startup.cs:

The call is ambiguous between the following methods or properties:

public void ConfigureServices(IServiceCollection services)
{

...

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

Error Details:

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

Second Issue:

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

Error Details:

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

What is the fix for these 2 issues?

like image 600
Krishnan Avatar asked Jun 24 '16 19:06

Krishnan


3 Answers

I also ran into this error in my migrations using dot net core 2.0. Hopefully this can help someone.

Error CS0115 'init.BuildTargetModel(ModelBuilder)': no suitable method found to override

It was after a refactoring where my migration classes had been moved a new namespace. I had moved them from MyApp.Migrations to MyApp.Web.Migrations and dot net did not like that.

I moved them back to MyApp.Migrations and they stopped complaining.

like image 114
span Avatar answered Nov 05 '22 09:11

span


I have found the solutions for both of the issues. I am posting it here which might be useful to others

First Issue

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

the Issue was with the following 2 config entries in Project.json. I replaced the existing entries with the following 2 and it solved the issues

 "Microsoft.AspNetCore.Identity": "1.0.0-rc2-final",
 "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-rc2-final",

Error CS0115 'CreateIdentitySchema.BuildTargetModel(ModelBuilder)': no suitable method found to override Firebolt.SecurityService..NETCoreApp,Version=v1.0

Find/Replace the existing using namespaces in all the migrations related classes

using Microsoft.Data.Entity with using Microsoft.EntityFrameworkCore
like image 21
Krishnan Avatar answered Nov 05 '22 09:11

Krishnan


I had Error

CS0115 'CreateIdentitySchema.BuildTargetModel(ModelBuilder)': no suitable method found to override Firebolt.SecurityService..NETCoreApp,Version=v1.0

The error pointed to a designer enter image description here As founded I am accidently change the name of migration file (the first file on the picture above) enter image description here

finally I have returned A back and everything continue working.

like image 2
Nikita Avatar answered Nov 05 '22 08:11

Nikita