Eshoponcontainers: Migration failed to add a field to the CatalogItem entity in CatalogContext of Catalog.API

Created on 14 Nov 2020  Â·  5Comments  Â·  Source: dotnet-architecture/eShopOnContainers

1.First, I added a String field: Tests

public string Tests { get; set; }

2.Then, to perform the migration:

 add - migration AddTests - c CatalogContext - o Infrastructure/CatalogMigrations

3.Finally, execute the project(or update-database) and report an error

image


After Debugging the source code, I found that the last migration record was not synchronized into the model snapshot.

This submission record has been modified.
(https://github.com/dotnet-architecture/eShopOnContainers/commit/45ed8a60ad87c0da8f84f93aae143dce7e9c8bcc)
But the snapshot file has not changed.
(https://github.com/dotnet-architecture/eShopOnContainers/blob/dev/src/Services/Catalog/Catalog.API/Infrastructure/CatalogMigrations/CatalogContextModelSnapshot.cs)

Causes new fields to be added to conflict.

bug

All 5 comments

The project only needs to modify the Model snapshot,

pic

and I can submit PR if necessary.

Hey @anjoy8, good to hear back from you again. :)

I quickly tried to run a migration by adding one Test string field and I was able to update the CatalogContextModelSnapshot class with new migration command.

dotnet ef migrations add AddTests -c CatalogContext -o Infrastructure/CatalogMigrations

But yes, there is some issues with PictureUri and now instead of that we have been using PictureFileName for the Catalog item. You may want to look into issue #1350 and propose the necessary changes.

Thank you

Hi, @sughosneo nice to hear from you again.

Regarding my issue, only need to modify the model snapshot.

On the issue of the (https://github.com/dotnet-architecture/eShopOnContainers/issues/1350), I have found the problem, do I need to submit a PR?

图片

Just change pictureFileName to lowercase.

pictureFileName -> picturefilename

need I need to submit a PR?

Hi, @sughosneo nice to hear from you again.

Regarding my issue, only need to modify the model snapshot.

On the issue of the (#1350), I have found the problem, do I need to submit a PR?

图片

Just change pictureFileName to lowercase.

pictureFileName -> picturefilename

need I need to submit a PR?

Yes, you are correct. I thought of pointing that one as well. Yes, you could submit two separate PRs with the respective changes.

Thank you.

Hi, I had intended to submit two PRs, but eventually merge together, https://github.com/dotnet-architecture/eShopOnContainers/pull/1520
I wonder if this meets your requirements.

In addition, there may still be some problems about Seed data, and I will further study it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wely picture wely  Â·  5Comments

CESARDELATORRE picture CESARDELATORRE  Â·  5Comments

Diggzinc picture Diggzinc  Â·  5Comments

andriyankrastevv picture andriyankrastevv  Â·  3Comments

adahhane picture adahhane  Â·  4Comments