Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 不更新数据库';不创建表_C#_Entity Framework_Entity Framework Migrations - Fatal编程技术网

C# 不更新数据库';不创建表

C# 不更新数据库';不创建表,c#,entity-framework,entity-framework-migrations,C#,Entity Framework,Entity Framework Migrations,我有5个SQL表,是用实体框架创建的。 但它不再创建表 我的背景: public class PlakappContext:DbContext { public DbSet<UserModel> User { get; set; } public DbSet<PostModel> Post { get; set; } public DbSet<PlateModel> Plate { get; set; }

我有5个SQL表,是用实体框架创建的。 但它不再创建表

我的背景:

 public class PlakappContext:DbContext
 {
        public DbSet<UserModel> User { get; set; }
        public DbSet<PostModel> Post { get; set; }
        public DbSet<PlateModel> Plate { get; set; }
        public DbSet<PostPlateModel> PostPlate { get; set; }
        public DbSet<PostImageModel> PostImage { get; set; }
        public DbSet<PostVoteModel> PostVote { get; set; }
}
我创建了所有的表,但无法为
PostVote
创建

另外
PostVoteModel

   public class PostVoteModel
   {
        [Key]
        public int VoteId { get; set; }
        public int VoteStatus { get; set; }
        public int PostId { get; set; }
        public int UserId { get; set; }
        public DateTime RegistrationDate { get; set; }
   }
更新:

Migration.cs:

public partial class Initial : DbMigration
    {
        public override void Up()
        {
        }

        public override void Down()
        {
        }
    }
internal sealed class Configuration : 

    DbMigrationsConfiguration<Plakapp.Data.PlakappContext>
        {
            public Configuration()
            {
                AutomaticMigrationsEnabled = true;
            }

            protected override void Seed(Plakapp.Data.PlakappContext context)
            {
                //  This method will be called after migrating to the latest version.

                //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
                //  to avoid creating duplicate seed data.
            }
        }
Configuration.cs:

public partial class Initial : DbMigration
    {
        public override void Up()
        {
        }

        public override void Down()
        {
        }
    }
internal sealed class Configuration : 

    DbMigrationsConfiguration<Plakapp.Data.PlakappContext>
        {
            public Configuration()
            {
                AutomaticMigrationsEnabled = true;
            }

            protected override void Seed(Plakapp.Data.PlakappContext context)
            {
                //  This method will be called after migrating to the latest version.

                //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
                //  to avoid creating duplicate seed data.
            }
        }
内部密封类配置:
DBMigrations配置
{
公共配置()
{
AutomaticMiggerationsEnabled=真;
}
受保护的覆盖无效种子(Plakapp.Data.PlakappContext上下文)
{
//迁移到最新版本后将调用此方法。
//您可以使用DbSet.AddOrUpdate()助手扩展方法
//避免创建重复的种子数据。
}
}

确切的错误是什么?@johnyingi我没有收到任何错误。更新数据库命令正在工作。因此,它返回了“Running seed method”。但它没有在SQL中创建表。您可以向我们展示您的
Configuration.cs
Migration
文件吗。另外,一些工具需要编译代码来检测新的迁移。您可以尝试构建应用程序,然后运行
更新数据库
命令。是否有PostVoteModel的迁移?@AdemCatamak我添加了configuration.cs和123_Initial.cs