Modifying DB

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
nbrglobalinc wrote:
Thanks for the reply but I checked everything and it is still throwing the same error.



I was facing a similar problem ,try my solution ,I hope it helps
https://www.nopcommerce.com/boards/t/8705/removing-edmx-file.aspx#35389
13 years ago
Hello,

I am having another problem with modifying database. In my case, I only get this error with the Customer table. This is my step to reproduce the error

1. Add one table in database, name ksu_Banner. This table has some fields: BannerID, Name, CreatedBy, CreatedDate
2. Create a relationship between CreatedBy and CustomerId in Customer table
3. Open edmx file, update changes from database and select new table
4. Delete the navigation property in Customer and Banner in edmx file
5. Create a class in Extension folder for new table
6. Build solution
7. Try to register new member, and i have this error


The changes to the database were committed successfully, but an error occurred while updating the object context. The ObjectContext might be in an inconsistent state. Inner exception message: There is no metadata information available for the proxy type for 'NopSolutions.NopCommerce.BusinessLogic.CustomerManagement.Customer'. This exception can be caused when a proxy type for an entity is detached from an ObjectContext. See InnerException for details.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The changes to the database were committed successfully, but an error occurred while updating the object context. The ObjectContext might be in an inconsistent state. Inner exception message: There is no metadata information available for the proxy type for 'NopSolutions.NopCommerce.BusinessLogic.CustomerManagement.Customer'. This exception can be caused when a proxy type for an entity is detached from an ObjectContext. See InnerException for details.

Source Error:


Line 1233:
Line 1234:            _context.Customers.AddObject(customer);
Line 1235:            _context.SaveChanges();
Line 1236:
Line 1237:            //reward points

Source File: D:\WORK\NOPCOMMERCE\nopCommerce_1.90_Source\Libraries\Nop.BusinessLogic\Customer\CustomerService.cs    Line: 1235

Stack Trace:


[InvalidOperationException: The changes to the database were committed successfully, but an error occurred while updating the object context. The ObjectContext might be in an inconsistent state. Inner exception message: There is no metadata information available for the proxy type for 'NopSolutions.NopCommerce.BusinessLogic.CustomerManagement.Customer'. This exception can be caused when a proxy type for an entity is detached from an ObjectContext. See InnerException for details.]
   System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options) +779
   System.Data.Objects.ObjectContext.SaveChanges() +15
   NopSolutions.NopCommerce.BusinessLogic.CustomerManagement.CustomerService.AddCustomerForced(Guid customerGuid, String email, String username, String passwordHash, String saltKey, Int32 affiliateId, Int32 billingAddressId, Int32 shippingAddressId, Int32 lastPaymentMethodId, String lastAppliedCouponCode, String giftCardCouponCodes, String checkoutAttributes, Int32 languageId, Int32 currencyId, TaxDisplayTypeEnum taxDisplayType, Boolean isTaxExempt, Boolean isAdmin, Boolean isGuest, Boolean isForumModerator, Int32 totalForumPosts, String signature, String adminComment, Boolean active, Boolean deleted, DateTime registrationDate, String timeZoneId, Int32 avatarId, Nullable`1 dateOfBirth) in D:\WORK\NOPCOMMERCE\nopCommerce_1.90_Source\Libraries\Nop.BusinessLogic\Customer\CustomerService.cs:1235
   NopSolutions.NopCommerce.BusinessLogic.CustomerManagement.CustomerService.AddCustomer(Guid customerGuid, String email, String username, String password, Int32 affiliateId, Int32 billingAddressId, Int32 shippingAddressId, Int32 lastPaymentMethodId, String lastAppliedCouponCode, String giftCardCouponCodes, String checkoutAttributes, Int32 languageId, Int32 currencyId, TaxDisplayTypeEnum taxDisplayType, Boolean isTaxExempt, Boolean isAdmin, Boolean isGuest, Boolean isForumModerator, Int32 totalForumPosts, String signature, String adminComment, Boolean active, Boolean deleted, DateTime registrationDate, String timeZoneId, Int32 avatarId, Nullable`1 dateOfBirth, MembershipCreateStatus& status) in D:\WORK\NOPCOMMERCE\nopCommerce_1.90_Source\Libraries\Nop.BusinessLogic\Customer\CustomerService.cs:1102
   NopSolutions.NopCommerce.BusinessLogic.CustomerManagement.CustomerService.AddCustomer(String email, String username, String password, Boolean isAdmin, Boolean isGuest, Boolean active, MembershipCreateStatus& status) in D:\WORK\NOPCOMMERCE\nopCommerce_1.90_Source\Libraries\Nop.BusinessLogic\Customer\CustomerService.cs:938
   NopSolutions.NopCommerce.BusinessLogic.Profile.StoreMembershipProvider.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status) in D:\WORK\NOPCOMMERCE\nopCommerce_1.90_Source\Libraries\Nop.BusinessLogic\Profile\StoreMembershipProvider.cs:101
   System.Web.UI.WebControls.CreateUserWizard.AttemptCreateUser() +302
   System.Web.UI.WebControls.CreateUserWizard.OnNextButtonClick(WizardNavigationEventArgs e) +111
   System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e) +413
   System.Web.UI.WebControls.CreateUserWizard.OnBubbleEvent(Object source, EventArgs e) +121
   System.Web.UI.WebControls.WizardChildTable.OnBubbleEvent(Object source, EventArgs args) +19
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +125
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +167
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563




I only have this error with the Customer table. I do same way with Product table (i.e create a new table and have productID as a foreign key) but I don't have error when adding new Product table.

Please help me to fix this issue.

thank you very much.
13 years ago
Hi,I had s similar problem ,why don't you try my post
https://www.nopcommerce.com/boards/t/8326/the-objectstatemanager-does-not-contain-an-objectstateentry-with-a-reference-to-an-object-of-type-systemdataentitydynamicproxiesorder_589f83608f1.aspx

I hop it help you
13 years ago
Thank you for your help. I tried but I have another error, still the same place, just different error message :(

The changes to the database were committed successfully, but an error occurred while updating the object context. The ObjectContext might be in an inconsistent state. Inner exception message: Metadata information for the relationship 'NopSolutions.NopCommerce.BusinessLogic.Data.FK_Tung_Banner_Nop_Customer' could not be retrieved. If mapping attributes are used, make sure that the EdmRelationshipAttribute for the relationship has been defined in the assembly.  When using convention-based mapping, metadata information for relationships between detached entities cannot be determined.
Parameter name: relationshipName

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The changes to the database were committed successfully, but an error occurred while updating the object context. The ObjectContext might be in an inconsistent state. Inner exception message: Metadata information for the relationship 'NopSolutions.NopCommerce.BusinessLogic.Data.FK_Tung_Banner_Nop_Customer' could not be retrieved. If mapping attributes are used, make sure that the EdmRelationshipAttribute for the relationship has been defined in the assembly.  When using convention-based mapping, metadata information for relationships between detached entities cannot be determined.
Parameter name: relationshipName
13 years ago
More information, although it throws error, the data is still written to database, but it is duplicated. It means there are two duplilcated record in database, and error is thrown on the web page.

And this issue only occurs with Customer table. I did the same steps with other table and there is no problem.

Thank you.
13 years ago
why don't you check your work according to the article in this post
https://www.nopcommerce.com/boards/t/6370/how-to-extending-nopcommerce.aspx
by retroviz
13 years ago
I did exactly like that post. BTW, in my application, my new tables have relationship with nop's tables. In that tutorial, the new table doesn't have relationship with nop's tables.
13 years ago
tibuchivn wrote:

2. Create a relationship between CreatedBy and CustomerId in Customer table

i miss that !
why don't you replaces CreatedBy by CustomerId in your table ,then in the query use
'select CustomerId as CreatedBy'  using this MSDN article
http://msdn.microsoft.com/en-us/library/bb896238.aspx#Y264
13 years ago
I don't think the name of the field is the reason for this issue. Actually I renamed the field, and the error still occurs. And the error only happens with table Nop_Customer. With other tables, there's no error when I add table with relationship ...
13 years ago
Hi, I think you may need help from one of the NC team members !!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.