Extend nopCommerce

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 年 前
Hi,

I am reposting it because last night I post it in the "Installation forum".

I am in the process of extending nopCommerce (version 1.80) to add a new entity.

I already read the article : http://blogs.planetcloud.co.uk/mygreatdiscovery/post/How-to-extend-nopCommerce.aspx which help me a lot but I still have few questions.

I notice that in nopCommerce database, sometimes the relations (FK) between table is not made, for exemple, the CustomerID in the Order table is not an FK to the Customer table, is there a reason for that? Is there a "rule" or a "pattern" that has been use by nopCommerce development for an easier integration with EF ?

I am new to Entity Framework, I never use it before. After I updated NopModel.edmx to add my new tables, I noticed that all the ID fields (for exemple CustomerID) that are FK has been added as Navigation Properties instead of Scalar Properties. Can I safely delete those Navigation Properties and create them (the FK) as  Scalar properties? Can this cause me future problem?

Thank you

Patrick
13 年 前
As I see it, the navigation properties are not being used at all. The foreign keys are there only for automatic removal of connected data. For example, when you remove a Product, then all CategoryProduct bindings will be automatically deleted.
Order is not connected to Customer, since orders should remain in the database even if the customer has been deleted.
13 年 前
If by "scalar properties" you mean CustomerID then the .edmx tracks both. Navigation properties are declared because they're appropriate--you have a foreign entity reference, after all--but if you don't need them e.g. because you don't want to implement lazy loading, I believe you can safely remove them and still have the CustomerID. Navigation properties are syntactic sugar.
13 年 前
Ok, thx for the informations guys
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.