I'm trying to add a new table which has 3 columns:
Id
PdfFileName
OrderProductVariantId

the OrderProductVariantId is a field for the FK pointing to table OrderProductVariant

I created all interface/class, it works fine if I do not add the FK.

Now, I added the FK, updated the model edmx file, then add to class:

public virtual CCC_OrderProductVariantPdfFile CCC_OrderProductVariantPdfFile { get; set; }

it compiled ok.

in the service, I have a method:

public CCC_OrderProductVariantPdfFile AddOrderProductVariantPdfFile(int orderProductVariantId, string filename)
        {
            filename = CommonHelper.EnsureMaximumLength(filename, 250);
            var orderProductVariantPdfFile = _context.CCC_OrderProductVariantPdfFile.CreateObject();
            
            orderProductVariantPdfFile.FileName = filename;
            orderProductVariantPdfFile.OrderProductVariantId = orderProductVariantId;
            orderProductVariantPdfFile.Valid = true;

            _context.CCC_OrderProductVariantPdfFile.AddObject(orderProductVariantPdfFile);
            _context.SaveChanges();

            return orderProductVariantPdfFile;
        }

to insert the record for the table, it created the error for the addobject:

The navigation property of type 'NopSolutions.NopCommerce.BusinessLogic.Widgets.CCC_OrderProductVariantPdfFile' is not a single implementation of 'System.Collections.Generic.ICollection`1[T]'.

(this happens whenever added a navigation property to the existing tables.)

any suggestions to fix this?


thanks


reader