移民
namespace MVSStore.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class New : DbMigration
{
public override void Up()
{
}
public override void Down()
{
}
}
}
连接的:
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
namespace MVSStore.Models.Data
{
public class Db : DbContext
{
public DbSet<PagesDTO> Pages { get; set; }
}
}
模型数据库
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;
namespace MVSStore.Models.Data
{
[Table("MVCStore")]
public class PagesDTO
{
[Key]
public int Id { get; set; }
public string Title { get; set; }
public string Slug { get; set; }
public string Body { get; set; }
public int Sorting { get; set; }
public bool HasSidebar { get; set; }
}
}
为什么迁移是空的?为什么没有创建字段?
第一次一切似乎都很好,然后我钝化了一些东西并删除了迁移文件夹。让我们创建新的,它们是空的
PM> get-migrations
Retrieving migrations that have been applied to the target database.
202104231114090_thr
202104231102309_sec
202104231041067_first
一切都比看起来容易得多。
name="XX" 应该建议连接类
以手动迁移为代价,我也从项目中删除了数据库。我更改了连接字符串,一切正常。