第一步:选择ASP.NET Core Web创建C#解决方案
第二步:重命名项目名称,创建项目
第三步:选择模板创建Web程序
第四步:安装三个NuGet包
Microsoft.EntityFrameworkCore.Design、Microsoft.EntityFrameworkCore.SqlServer、Microsoft.EntityFrameworkCore.Tools
第五步:项目Models文件夹添加类文件
public class Blog
{
public int BlogId { get; set; }
public string Url { get; set; }
public virtual 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; }
}