Visual studio 2013 获取表时出错,我没有使用实体框架代码优先方法创建该表。错误是无效的对象名称“0”;XXXX“;

Visual studio 2013 获取表时出错,我没有使用实体框架代码优先方法创建该表。错误是无效的对象名称“0”;XXXX“;,visual-studio-2013,asp.net-mvc-5,ef-code-first,ef-code-first-mapping,Visual Studio 2013,Asp.net Mvc 5,Ef Code First,Ef Code First Mapping,初始迁移代码在下面,我从未创建过dbo.StudentEvent1,但使用此数据库运行asp.net MVC应用程序时出错 CreateTable( "dbo.StudentEvents", c => new { StudentId = c.Int(nullable: false), EventId = c.Int(nullable

初始迁移代码在下面,我从未创建过
dbo.StudentEvent1
,但使用此数据库运行asp.net MVC应用程序时出错

CreateTable(
            "dbo.StudentEvents",
            c => new
                {
                    StudentId = c.Int(nullable: false),
                    EventId = c.Int(nullable: false),
                    isAttended = c.Boolean(nullable: false),
                })
            .PrimaryKey(t => new { t.StudentId, t.EventId })
            .ForeignKey("dbo.Events", t => t.EventId, cascadeDelete: true)
            .ForeignKey("dbo.Students", t => t.StudentId, cascadeDelete: true)
            .Index(t => t.StudentId)
            .Index(t => t.EventId);

        CreateTable(
            "dbo.TeacherEvents",
            c => new
                {
                    TeacherId = c.Int(nullable: false),
                    EventId = c.Int(nullable: false),
                    Duties = c.String(),
                })
            .PrimaryKey(t => new { t.TeacherId, t.EventId })
            .ForeignKey("dbo.Events", t => t.EventId, cascadeDelete: true)
            .ForeignKey("dbo.Teachers", t => t.TeacherId, cascadeDelete: true)
            .Index(t => t.TeacherId)
            .Index(t => t.EventId);

打开package manager控制台并选择默认项目

然后,
启用迁移
用于启用迁移 然后将
添加迁移
添加到迁移中的更改中 然后将
更新数据库
应用于数据库

请参考以下链接:
http://www.entityframeworktutorial.net/code-first/code-based-migration-in-code-first.aspx

谢谢