Entity Framework from scratch

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 13 ans
Hi,

I would like to know how nopCommerce team have generated the classes (POCOs?) and Contexts on their own structure of namespaces...there's any manual work? I am asking because examples I saw generated these classes under a .tt file or as partial classes under the .Designer.cs of the model file, and I could not find any of those in the solution and we are thinking about modeling the introduction of new entities.

Thanks
Il y a 13 ans
They are hand-crafted
Il y a 13 ans
Thanks for the reply.

So it means that EntityType attribute of NopModel.edmx is also hand-crafted?
I imagine that at first time, you generated the classes from database and then disabled the automatic generation, or something like this?
Il y a 13 ans
Another question, to complement the last one: what when you need to add a new attribute to some entity? You add the column to database (if needed), synchronize the model with database and than manually adds the new attribute (property) to the entity?
Il y a 13 ans
carrbrpoa wrote:
I imagine that at first time, you generated the classes from database and then disabled the automatic generation, or something like this?

All of them were hand-crafted (previously we didn't use EF, and they already existed)

carrbrpoa wrote:
what when you need to add a new attribute to some entity? You add the column to database (if needed), synchronize the model with database and than manually adds the new attribute (property) to the entity?

Correct
Il y a 13 ans
Thanks, it cleared my initial doubts. Resolved!
Il y a 12 ans
I am not sure why but i am getting this error on adding a new entity ProductSubtopic
exc = {"The ObjectStateManager does not contain an ObjectStateEntry with a reference to an object of type 'NopSolutions.NopCommerce.BusinessLogic.ProductTopics.ProductSubtopic'."}

I added another entity following the same steps it works fine, please help me out i am new at this
Il y a 12 ans
hemant wrote:
I am not sure why but i am getting this error on adding a new entity ProductSubtopic
exc = {"The ObjectStateManager does not contain an ObjectStateEntry with a reference to an object of type 'NopSolutions.NopCommerce.BusinessLogic.ProductTopics.ProductSubtopic'."}

I added another entity following the same steps it works fine, please help me out i am new at this


This happens at entry = context.ObjectStateManager.GetObjectStateEntry(entity); in  class Extensions.cs

Method isAttached
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.