Reputation: 1008
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?
Upvotes: 9
Views: 10123
Reputation: 1605
Place YourMigration.cs
file and YourMigration.Designer.cs
partial file to the same namespace
Upvotes: 0
Reputation: 63
I have the same solution as @span Migrations were moved from the .Web.
project to the .Database.
project. But my migration still was in Web
. It causes with error. Following @span solution, I just changed the namespace of the migration and it works!
Upvotes: 0
Reputation: 1082
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.
Upvotes: 4
Reputation: 1008
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
Upvotes: 2
Reputation: 5624
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.
Upvotes: 26