Skip to content

Commit

Permalink
migrated Identity project to core 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alimon808 committed Sep 12, 2017
1 parent e58ef22 commit ec4428c
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 230 deletions.
56 changes: 1 addition & 55 deletions ContosoUniversity.Data/ApplicationContextFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.Extensions.Configuration;
using System;
using System.IO;
Expand All @@ -20,61 +19,8 @@ public ApplicationContext CreateDbContext(string[] args)
.Build();

var builder = new DbContextOptionsBuilder<ApplicationContext>();
builder.UseSqlServer(config.GetConnectionString("DefaultConnection"));
builder.UseSqlServer(config.GetConnectionString("DefaultConnection"), x => x.MigrationsHistoryTable("Migration", "Contoso"));
return new ApplicationContext(builder.Options);
}

//public ApplicationContext Create()
//{
// var environmentName = Environment.GetEnvironmentVariable("Hosting:Environment");
// var basePath = AppContext.BaseDirectory;

// return Create(basePath, environmentName);
//}

//private ApplicationContext Create(string basePath, string environmentName)
//{
// var builder = new ConfigurationBuilder()
// .SetBasePath(basePath)
// .AddJsonFile("appsettings.json")
// .AddJsonFile($"appsettings.{environmentName}.json", true)
// .AddEnvironmentVariables();

// var config = builder.Build();

// var connstr = config.GetConnectionString("DefaultConnection");

// if (String.IsNullOrWhiteSpace(connstr))
// {
// throw new InvalidOperationException("Could not find a connection string named 'DefaultConnection'");
// }

// return Create(connstr);
//}

//private ApplicationContext Create(string connectionString)
//{
// if (string.IsNullOrEmpty(connectionString))
// {
// throw new ArgumentException($"{nameof(connectionString)} is null or empty");
// }

// var optionsBuilder = new DbContextOptionsBuilder<ApplicationContext>();
// optionsBuilder.UseSqlServer(connectionString, x => x.MigrationsHistoryTable("Migration", "Contoso"));

// return new ApplicationContext(optionsBuilder.Options);
//}

////public ApplicationContext Create(DbContextFactoryOptions options)
////{
//// return Create(options.ContentRootPath, options.EnvironmentName);
////}

//public ApplicationContext Create(DbContextFactoryOptions options)
//{
// return Create(Directory.GetCurrentDirectory(), Environment.GetEnvironmentVariable("Hosting:Environment"));
//}


}
}
2 changes: 1 addition & 1 deletion ContosoUniversity.Identity/ApplicationUser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity;

namespace ContosoUniversity.Identity
{
Expand Down
15 changes: 8 additions & 7 deletions ContosoUniversity.Identity/ContosoUniversity.Identity.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.1" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
</ItemGroup>
</Project>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ec4428c

Please sign in to comment.