Makes AddEntityFrameworkStores use TryAdd instead of Add

This commit is contained in:
eduaglz 2015-06-17 16:03:26 -05:00
parent 8796f7e78a
commit 741f2b1cc7
1 changed files with 2 additions and 2 deletions

View File

@ -12,7 +12,7 @@ namespace Microsoft.Framework.DependencyInjection
public static IdentityBuilder AddEntityFrameworkStores<TContext>(this IdentityBuilder builder) public static IdentityBuilder AddEntityFrameworkStores<TContext>(this IdentityBuilder builder)
where TContext : DbContext where TContext : DbContext
{ {
builder.Services.Add(IdentityEntityFrameworkServices.GetDefaultServices(builder.UserType, builder.RoleType, typeof(TContext))); builder.Services.TryAdd(IdentityEntityFrameworkServices.GetDefaultServices(builder.UserType, builder.RoleType, typeof(TContext)));
return builder; return builder;
} }
@ -20,7 +20,7 @@ namespace Microsoft.Framework.DependencyInjection
where TContext : DbContext where TContext : DbContext
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
builder.Services.Add(IdentityEntityFrameworkServices.GetDefaultServices(builder.UserType, builder.RoleType, typeof(TContext), typeof(TKey))); builder.Services.TryAdd(IdentityEntityFrameworkServices.GetDefaultServices(builder.UserType, builder.RoleType, typeof(TContext), typeof(TKey)));
return builder; return builder;
} }
} }