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?
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.
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
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 As founded I am accidently change the name of migration file (the first file on the picture above)
finally I have returned A
back and everything continue working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With