Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.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
Entity framework 无法通过先使用实体框架代码迁移现有数据库来更改表名_Entity Framework_Ef Code First_Entity Framework Migrations - Fatal编程技术网

Entity framework 无法通过先使用实体框架代码迁移现有数据库来更改表名

Entity framework 无法通过先使用实体框架代码迁移现有数据库来更改表名,entity-framework,ef-code-first,entity-framework-migrations,Entity Framework,Ef Code First,Entity Framework Migrations,在对现有数据库首先使用ef代码进行迁移时,尝试更改表名时出现问题。在现有的数据库中,我得到了一个表名“Cities”,我想把它改为“City”。在映射文件中,我声明: public CityMap() { // Primary Key this.HasKey(t => t.CityId); // Properties this.Property(t => t.CityCode) .Has

在对现有数据库首先使用ef代码进行迁移时,尝试更改表名时出现问题。在现有的数据库中,我得到了一个表名“Cities”,我想把它改为“City”。在映射文件中,我声明:

public CityMap()
    {
        // Primary Key
        this.HasKey(t => t.CityId);

        // Properties
        this.Property(t => t.CityCode)
            .HasMaxLength(64);

        this.Property(t => t.Name)
            .HasMaxLength(128);

        this.Property(t => t.SysNo)
            .HasMaxLength(64);

        this.Property(t => t.No_Ins)
            .HasMaxLength(64);

        this.Property(t => t.CountryCode)
            .HasMaxLength(64);

        // Table & Column Mappings
        this.ToTable("City");
        this.Property(t => t.CityId).HasColumnName("CityId");
        this.Property(t => t.CityCode).HasColumnName("CityCode");
        this.Property(t => t.Name).HasColumnName("Name");
        this.Property(t => t.SysNo).HasColumnName("SysNo");
        this.Property(t => t.No_Ins).HasColumnName("No.Ins");
        this.Property(t => t.CountryId).HasColumnName("CountryId");
        this.Property(t => t.CountryCode).HasColumnName("CountryCode");
        this.Property(t => t.Note).HasColumnName("Note");

        // Relationships
        this.HasRequired(t => t.Country)
            .WithMany(t => t.Cities)
            .HasForeignKey(d => d.CountryId);

    }
之后,我执行迁移命令“addmigrationinitial-ignorechanges”和“updatedatabase-verbose”,但在现有数据库中什么也没有发生。我错过什么了吗?非常感谢你