Entity framework 无法通过先使用实体框架代码迁移现有数据库来更改表名
在对现有数据库首先使用ef代码进行迁移时,尝试更改表名时出现问题。在现有的数据库中,我得到了一个表名“Cities”,我想把它改为“City”。在映射文件中,我声明: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
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”,但在现有数据库中什么也没有发生。我错过什么了吗?非常感谢你