What's the Optimal Solution for Resolving a 'Table Doesn't Exist' Error in MySQL when Adding a Custom Variable?

3 months ago
I am encountering an issue related to a custom variable added to the table, and I am receiving the following error message: MySqlConnector.MySqlException: 'Table 'noopcommerce.productpicture' doesn't exist. The error is associated with the following code snippet:

Create.Column(nameof(ProductPicture.CustomNameOfAVariable))
    .OnTable(nameof(ProductPicture))
    .AsInt32()
    .Nullable();

To address this problem, what would be the most effective solution?
3 months ago
what is your nopCommerce version?
you create a table from  Up Migration after checking table exists or not and create a column after that
check this topic thread
https://www.nopcommerce.com/fr/boards/topic/84846/adding-a-new-table-or-a-field-to-existing-table-n-nopcommerce-43/page/2#297341

//Rashed
3 months ago
I've followed the guidance provided in this forum topic, incorporating the provided code into the source files for 'ProductPicture.cs.' Subsequently, I introduced a new custom class, akin to the instructions in the forum. The specific table I'm aiming to modify is 'product_picture_mapping.'

My query is whether there's an option to execute this migration through a custom plugin, eliminating the need to modify the core source code. If such an option exists, could you please guide me on how to achieve this? I aim to override with my 'CustomProductPicture.cs' to add the necessary custom variables to be stored in the database. The version I'm currently using is 4.60.2.
3 months ago
Yes you can add a table using a Plugin
for example see Nop.Plugin.Shipping.FixedByWeightByTotal
3 months ago
Yidna wrote:
Yes you can add a table using a Plugin
for example see Nop.Plugin.Shipping.FixedByWeightByTotal

I'm aware of the existing options, but my specific inquiry is whether it's feasible to modify an existing table through a custom plugin. Essentially, I'm looking to have control over the columns within the 'Category' table. Is such customization achievable through a custom plugin?
3 months ago
nedelko.klemen.pharmaco wrote:
...feasible to modify an existing table through a custom plugin...?

No it is not.
Consider using a GenericAttribute.
3 months ago
New York wrote:

No it is not.
Consider using a GenericAttribute.

Do you got some example/best practice how to achive that?
If I understand correctly, when you want to include additional custom parameters in the database table using a custom plugin, the recommended approach is to create a new custom table. This table should have a foreign key (FK) linked to the "Category" table, connecting it to the new custom table.