diff --git a/src/Microsoft.AspNet.Identity.Entity/EntityServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Identity.Entity/EntityServiceCollectionExtensions.cs new file mode 100644 index 0000000000..c8b308309f --- /dev/null +++ b/src/Microsoft.AspNet.Identity.Entity/EntityServiceCollectionExtensions.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNet.Identity; +using Microsoft.AspNet.Identity.Entity; +using Microsoft.Data.Entity; + +namespace Microsoft.Framework.DependencyInjection +{ + public static class EntityServiceCollectionExtensions + { + public static ServiceCollection AddEntity(this ServiceCollection services) + where TUser : User + { + services.AddScoped, UserStore>(); + services.AddScoped>(); + return services; + } + + public static ServiceCollection AddEntity(this ServiceCollection services) + where TUser : User where TContext : DbContext + { + services.AddEntity(); + services.AddScoped(); + return services; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Identity.Entity/IdentitySqlContext.cs b/src/Microsoft.AspNet.Identity.Entity/IdentitySqlContext.cs index 8ebdc0050e..a17ca10aa9 100644 --- a/src/Microsoft.AspNet.Identity.Entity/IdentitySqlContext.cs +++ b/src/Microsoft.AspNet.Identity.Entity/IdentitySqlContext.cs @@ -2,10 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.Framework.DependencyInjection; -using Microsoft.Framework.DependencyInjection.Fallback; using Microsoft.Data.Entity; -using Microsoft.Data.Entity.SqlServer; using Microsoft.Data.Entity.Metadata; namespace Microsoft.AspNet.Identity.Entity @@ -33,7 +30,7 @@ namespace Microsoft.AspNet.Identity.Entity protected override void OnConfiguring(DbContextOptions builder) { // TODO: pull connection string from config - builder.UseSqlServer(@"Server=(localdb)\v11.0;Database=SimpleIdentity5;Trusted_Connection=True;"); + builder.UseSqlServer(@"Server=(localdb)\v11.0;Database=SimpleIdentity;Trusted_Connection=True;"); } protected override void OnModelCreating(ModelBuilder builder) diff --git a/src/Microsoft.AspNet.Identity.Security/SecurityServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Identity.Security/SecurityServiceCollectionExtensions.cs new file mode 100644 index 0000000000..82a7bce310 --- /dev/null +++ b/src/Microsoft.AspNet.Identity.Security/SecurityServiceCollectionExtensions.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNet.Identity.Security; + +namespace Microsoft.Framework.DependencyInjection +{ + public static class SecurityServiceCollectionExtensions + { + public static ServiceCollection AddSecurity(this ServiceCollection services) + where TUser : class + { + services.AddTransient>(); + return services; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Identity/IdentityServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Identity/IdentityServiceCollectionExtensions.cs index b6151613e6..480509748d 100644 --- a/src/Microsoft.AspNet.Identity/IdentityServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNet.Identity/IdentityServiceCollectionExtensions.cs @@ -8,7 +8,7 @@ namespace Microsoft.Framework.DependencyInjection { public static class IdentityServiceCollectionExtensions { - public static ServiceCollection AddIdentity(this ServiceCollection services, Action> actionBuilder) + public static ServiceCollection AddIdentity(this ServiceCollection services) where TUser : class where TRole : class { @@ -16,10 +16,24 @@ namespace Microsoft.Framework.DependencyInjection services.Add(IdentityServices.GetDefaultRoleServices()); services.AddTransient, IdentityOptionsSetup>(); services.AddSingleton, OptionsAccessor>(); + return services; + } + + public static ServiceCollection AddIdentity(this ServiceCollection services, Action> actionBuilder) + where TUser : class + where TRole : class + { + services.AddIdentity(); actionBuilder(new IdentityBuilder(services)); return services; } + public static ServiceCollection AddIdentity(this ServiceCollection services) + where TUser : class + { + return services.AddIdentity(); + } + public static ServiceCollection AddIdentity(this ServiceCollection services, Action> actionBuilder) where TUser : class {