- What is your product version?
- 5.2
- What is your product type (Angular or MVC)?
- Angular
- What is product framework type (.net framework or .net core)?
- .net Core
If issue related with ABP Framework
- What is ABP Framework version?
- 5.2
Issue: I am using Code First approach for creating the database. My Database is in postgres as backend and i am using asp.net core for API development. I have modidifed my table as Following Added Following column in the table structure
public virtual int? OEMarketplaceProviderId { get; set; }
[ForeignKey("OEMarketplaceProviderId")]
public virtual OEMarketPlaceProvider OEMarketplaceProviderIdFK { get; set; }
public virtual string LongDescription { get; set; }
public virtual int? OEEnumNotificationStatusId { get; set; }
[ForeignKey("OEEnumNotificationStatusId")]
public OEEnumMaster OEEnumNotificationStatusFk { get; set; }
// inplace of OESystemStatusMasterId
public virtual int? Status { get; set; }
[ForeignKey("Status")]
public OEEnumMaster StatusFk { get; set; }
Migration Generated
migrationBuilder.AddColumn<int>(
name: "OEEnumNotificationStatusId",
table: "OESystem",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "OEEnumNotificationStatusId",
table: "OESystem",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "OEMarketplaceProviderId",
table: "OESystem",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "OEMarketplaceProviderId",
table: "OESystem",
nullable: true);
-
Snapshot Generated
b.HasOne("OneEnterprise.iHUB.OEEnumMasters.OEEnumMaster", "OEEnvironmentMasterFk")
.WithMany()
.HasForeignKey("OEEnvironmentMasterId");
b.HasOne("OneEnterprise.iHUB.OEMarketPlaceProviders.OEMarketPlaceProvider", "OEMarketplaceProviderIdFK")
.WithMany()
.HasForeignKey("OEMarketplaceProviderId​​");
b.HasOne("OneEnterprise.iHUB.OEEnumMasters.OEEnumMaster", "OESystemStatusMasterFk")
.WithMany()
.HasForeignKey("OESystemStatusMasterId");
b.HasOne("OneEnterprise.iHUB.OEEnumMasters.OEEnumMaster", "StatusFk")
.WithMany()
.HasForeignKey("Status​​");
b.HasOne("OneEnterprise.iHUB.SystemSpecification.SystemInfo", "SystemInfoFk")
.WithMany()
.HasForeignKey("SystemInfoId");
Related Entity
[Required]
public virtual string Name { get; set; }
public virtual string Code { get; set; }
public virtual string Description { get; set; }
public virtual string NameLanguageId { get; set; }
public virtual string DescriptionLanguageId { get; set; }
public virtual string ToolTip { get; set; }
public virtual string ToolTipLanguageId { get; set; }
public virtual string HelpId { get; set; }
public virtual EnumType EnumType { get; set; }
public virtual bool IsDefault { get; set; }
Entity 2
public virtual string Description { get; set; }
public virtual string Address { get; set; }
public virtual string Phone { get; set; }
public virtual string Mail { get; set; }
public virtual string Website { get; set; }
public virtual int OEBusinessPartnerId { get; set; }
[ForeignKey("OEBusinessPartnerId")]
public OEBusinessPartner OEBusinessPartnerFk { get; set; }
public virtual int? OEEnumMasterBusinessPartnerStatusId { get; set; }
[ForeignKey("OEEnumMasterBusinessPartnerStatusId")]
public OEEnumMaster OEEnumMasterBusinessPartnerStatusFk { get; set; }
public virtual int? OEMarketPlaceOfferId { get; set; }
[ForeignKey("OEMarketPlaceOfferId")]
public OEMarketPlaceOffer OEMarketPlaceOfferFk { get; set; }
public virtual int? OEMarketPlaceRatingId { get; set; }
[ForeignKey("OEMarketPlaceRatingId")]
public OEMarketPlaceRating OEMarketPlaceRatingFk { get; set; }
Please suggest what could be the reason and if is Deployed in the Testing environment. How we can fix it. In Snapshot we can easily check that duplicate column has been created in Migration and snapshot, however in entity i have placed the column name only once
thanks Ashish
10 Answer(s)
-
0
Hi @mahendra
I couldn't find any related issue in npgsql GitHub repository. You can try to upgrade npgsql version to latest possible version. Then, you can modify this migration manually to remove the duplicate field generation.
I think, if you try to apply this migration, it will fail since it will not be able to create the same field twice.
-
0
Hi ismcagdas ,
Still Column with same column is Created, we are not getting any issue. I think remove column from the migration is not a good idea.
Thanks Ashish
-
0
Hi @mahendra
If you can share your project via email with [email protected], we can try to take a deeper look but I'm not sure if we can find another solution or not.
Thanks,
-
0
-
0
Hi Expert,
I have shared the zip in given in your given mail. Looking forward for help from you .
Thanks Ashish Mohan
-
0
Hi Expert , I have shared the zip in given in the following mailId ([email protected]). Any help will be much appreciated. Waiting for your response.
Thanks Ashish
-
0
Hi Expert,
Any update for us. Looking forward to hear from you soon. We are stuck due to this issue.
Thanks Ashish
-
0
The source of the error you mentioned is migrations. I removed your migrations and generate a fresh one. It all worked. I did research within migrations but could not see the exact source of the error.
-
0
Hi musa.demir,
Thanks for your response.
**Have you removed all the migration and generated the new Migration ? **
Note : We are facing this issue only for the foregin key column. I tried again and facing same issue.
Table Class where added the column OEEnumNotificationStatusId
[Table("OESolutionProcessLink")] public class OESolutionProcessLink : Entity { public virtual int OESolutionId { get; set; } [ForeignKey("OESolutionId")] public OESolution OESolutionFk { get; set; } public virtual int OEProcessId { get; set; } [ForeignKey("OEProcessId")] public OEProcess OEProcessFk { get; set; } public virtual int? OEEnumNotificationStatusId { get; set; } [ForeignKey("OEEnumNotificationStatusId")] public OEEnumMaster OEEnumNotificationStatusFk { get; set; } }
Following Migration is Generated When i Change the Encoding to ANSI, i noticed that there are some special characters in the migration for the column OEEnumNotificationStatusId namespace OneEnterprise.iHUB.Migrations { public partial class addedIssueColumn : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn<int>( name: "OEEnumNotificationStatusId", table: "OESolutionProcessLink", nullable: true);
migrationBuilder.AddColumn<int>( name: "OEEnumNotificationStatus​Id​", table: "OESolutionProcessLink", nullable: true); migrationBuilder.CreateIndex( name: "IX_OESolutionProcessLink_OEEnumNotificationStatus​Id​", table: "OESolutionProcessLink", column: "OEEnumNotificationStatus​Id​"); migrationBuilder.AddForeignKey( name: "FK_OESolutionProcessLink_OEEnumMaster_OEEnumNotificationStatus~", table: "OESolutionProcessLink", column: "OEEnumNotificationStatus​Id​", principalTable: "OEEnumMaster", principalColumn: "Id", onDelete: ReferentialAction.Restrict); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_OESolutionProcessLink_OEEnumMaster_OEEnumNotificationStatus~", table: "OESolutionProcessLink"); migrationBuilder.DropIndex( name: "IX_OESolutionProcessLink_OEEnumNotificationStatus​Id​", table: "OESolutionProcessLink"); migrationBuilder.DropColumn( name: "OEEnumNotificationStatusId", table: "OESolutionProcessLink"); migrationBuilder.DropColumn( name: "OEEnumNotificationStatus​Id​", table: "OESolutionProcessLink"); } }
}
-
0
Hi @mahendra Yes, I have removed all migrations and created a fresh one. That also solved the problem. You can also check https://support.aspnetzero.com/QA/Questions/10155/Duplicate-Column-with-same-name-is-getting-Creating-when-using-Code-First-Approach-postgres#answer-5eac3cfb-5f57-c467-8e2b-39fb32833e3b. The problem seems to be in npgsql.