私は.NETを初めて使い、現在ASP.NETコアMVCを学習しており、this tutorialに従っています。モデル/ IdentityModel.csがありません
私の開発環境:
- のUbuntu 16.04.1 LTS
- ネットコア1.0.0-preview2-1-003177
- Visual Studioのコード1.7.2
- 発電ASPNET 0.2 .5(プロジェクトの足場を作成する)
これは長い巻頭の質問ですので、私と一緒に裸にしてください。
したがって、yo aspnet
を使用して新しいプロジェクトを作成し、個別のユーザーアカウントベースの認証を含むWeb Application
を選択しました。このチュートリアルでは、「モデルを作成する」セクションに進んで、進め方を混乱させています。
具体的には、モデルは、チュートリアルでは、次のようにルックスを作成するように要求されます:
モデル/ Model.cs:
:using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
namespace EFGetStarted.AspNetCore.NewDb.Models
{
public class BloggingContext : DbContext
{
public BloggingContext(DbContextOptions<BloggingContext> options)
: base(options)
{ }
public DbSet<Blog> Blogs { get; set; }
public DbSet<Post> Posts { get; set; }
}
public class Blog
{
public int BlogId { get; set; }
public string Url { get; set; }
public List<Post> Posts { get; set; }
}
public class Post
{
public int PostId { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public int BlogId { get; set; }
public Blog Blog { get; set; }
}
}
しかし、そのページに、警告があります
あなたが認証 のために代わりなしで個々のユーザーアカウントを使用する場合は、Entity Frameworkのモデルは01でプロジェクトに追加されますModels \ IdentityModel.cs。この ウォークスルーで学ぶテクニックを使用して、2番目のモデルを追加するか、この 既存モデルを拡張してエンティティクラスを追加することができます。
Models/IdentityModel.csが参照するファイルが見つからないときに混乱が生じました。私はこのようになりますこれは、モデル/ ApplicationUser.csを参照してください。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
namespace EFGetStarted.AspNetCore.NewDb.Models
{
// Add profile data for application users by adding properties to the ApplicationUser class
public class ApplicationUser : IdentityUser
{
}
}
...とこのようになりますデータ/ ApplicationDBContext.cs、:したがって、基本的
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using EFGetStarted.AspNetCore.NewDb.Models;
namespace EFGetStarted.AspNetCore.NewDb.Data
{
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
// Customize the ASP.NET Identity model and override the defaults if needed.
// For example, you can rename the ASP.NET Identity table names and more.
// Add your customizations after calling base.OnModelCreating(builder);
}
}
}
上記の警告メッセージは、どのように進めるのか混乱しています。 Models/IdentityModel.csは存在しないため、Model.csの内容をModels/ApplicationUser.csまたはData/ApplicationDBContext.csに配置するか、すべてそのままにしますか?
はあなたの助けをありがとう:)