Modifying DB

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 年 前
aduarte wrote:
Here is a brief tutorial:
1. Create a new table (for example, Nop_Customer)
2. "Update model from database" for NopModel.edmx
3. Create an appropriate class in your business logic (for example, Customer)
4. Add an appropriate ObjectSet property to NopObjectContext

That's all

the shortest and most useful tutorial ever, thanks a lot.. :)



I was followed the steps and i was added one entity in model and also create entityset and business logic class but i was run the program an error occure in LogManger.cs page and my site give an error.
so give me a solution..

Dipesh Jade (India)
13 年 前
so give us the error...
13 年 前
Dipesh2010 wrote:
Here is a brief tutorial:
1. Create a new table (for example, Nop_Customer)
2. "Update model from database" for NopModel.edmx
3. Create an appropriate class in your business logic (for example, Customer)
4. Add an appropriate ObjectSet property to NopObjectContext

That's all

the shortest and most useful tutorial ever, thanks a lot.. :)


I was followed the steps and i was added one entity in model and also create entityset and business logic class but i was run the program an error occure in NopObjectContext and my site give an error.

  public ObjectSet<CustomerSession> CustomerSessions
        {
            get
            {
                if ((_customerSessions == null))
                {
                   _customerSessions = CreateObjectSet<CustomerSession>(); ======> Error in this line
                }
                return _customerSessions;
            }
        }

Error : Schema specified is not valid. Errors:
The relationship 'NopSolutions.NopCommerce.BusinessLogic.Data.FK_Nop_TierPrice_Nop_ProductVariant' was not loaded because the type 'NopSolutions.NopCommerce.BusinessLogic.Data.TierPrice' is not available.
The following information may be useful in resolving the previous error:
The required property 'DiscountRate' does not exist on the type 'NopSolutions.NopCommerce.BusinessLogic.Products.TierPrice

so give me a solution..

Dipesh Jade (India)
13 年 前
Hello Dipesh,

"The required property 'DiscountRate' does not exist on the type 'NopSolutions.NopCommerce.BusinessLogic.Products.TierPrice"

As it seems, the alteration you did involves adding a propertie called DiscountRate, which you need to manually add to the class TierPrice.
13 年 前
Hi Experts,
I am regular user of NopCommerce but mostly i was working in previous  version <1.7. But now i started nopCommerce 1.7 in 2010 VS.

1.
I added one table called :
tjq_users actually this was in my previous e-commerce.

Having Field Like:

public partial class tjq_Users : BaseEntity
    {
        public tjq_Users()
        {
        }
        public int UserID { get; set; }
        public int UserAccessLevel { get; set; }
        public DateTime UserDateStamp { get; set; }
        public bool UserValidated { get; set; }
        public DateTime UserLastAccessDate { get; set; }
        public bool UserActive { get; set; }
        public DateTime UserExpirationDate { get; set; }
        public bool UserNews { get; set; }
        public bool UserMailingList { get; set; }
        public DateTime UserSubscribeDate { get; set; }
        public DateTime UserSubscribeCancelDate { get; set; }
        public string UserSubscriptionDescription { get; set; }
        public int UserSubscriptionTerm = 1;
        public float UserMonthlyRate { get; set; }
        public DateTime UserNextChargeDate { get; set; }
        public float UserNextChargeAmount { get; set; }
      
        public string UserEmailAddress { get; set; }
        public string UserFirstName { get; set; }
        public string UserLastName { get; set; }
        public string UserPassword { get; set; }
        public bool UserNotifyForumPostAll{get;set;}
        public bool UserNotifyNews{get;set;}
        public bool UserNotifyForumPostRelated{get;set;}
        public bool UserNotifyBlogPost { get; set; }
        public string UserNickName { get; set; }
        public string UserReferralAffiliateID { get; set; }
        public int UserReferralUserID { get; set; }
        
     }
Its because i just want to store user information in both system from NopCommerce registration Form.

2. I did pull in the NopModel.edmx.
3. get inside of NopObjectContext.css and added following code:
  public ObjectSet<tjq_Users> tjq_Users
        {
            get
            {
                if ((_tjq_Users == null))
                {
                    _tjq_Users = CreateObjectSet<tjq_Users>();
                }
                return _tjq_Users;
            }

        }
        private ObjectSet<tjq_Users> _tjq_Users;
4.  I did call on CustomerManager.cs like below
var tjq = context.tjq_Users.CreateObject();

            tjq.UserID = 0;
            tjq.UserFirstName = "sunil";
            tjq.UserLastName = "paudel";
            tjq.UserEmailAddress = "[email protected]";
            tjq.UserPassword = "password";
            tjq.UserReferralAffiliateID = "aaaa";
            tjq.UserNotifyForumPostAll = true;
            tjq.UserNotifyNews = true;
            tjq.UserNotifyForumPostRelated = true;
            tjq.UserNotifyBlogPost = true;
            tjq.UserNickName = "test name";
            tjq.UserReferralUserID = 1;
            tjq.UserAccessLevel = 0;
            tjq.UserDateStamp = DateTime.Now;
            tjq.UserValidated = true;
            tjq.UserLastAccessDate = DateTime.Now;
            tjq.UserActive = true;
            tjq.UserExpirationDate = DateTime.Now.AddDays(300);
            tjq.UserNews = false;
            tjq.UserMailingList = false;
            tjq.UserSubscribeDate = DateTime.Now;
            tjq.UserSubscribeCancelDate = DateTime.Now.AddDays(300);
            tjq.UserSubscriptionDescription = "teest";
            tjq.UserSubscriptionTerm = 1;
            tjq.UserMonthlyRate = 1010;
            tjq.UserNextChargeDate = DateTime.Now.AddDays(300);
            tjq.UserNextChargeAmount = 100;
            context.tjq_Users.AddObject(tjq);
           context.SaveChanges();
5. Finally i get following error

Mapping and metadata information could not be found for EntityType 'NopSolutions.NopCommerce.BusinessLogic.tjq_UsersManagement.tjq_Users'.
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: Mapping and metadata information could not be found for EntityType 'NopSolutions.NopCommerce.BusinessLogic.tjq_UsersManagement.tjq_Users'.

Source Error:

Line 108:                if ((_tjq_Users == null))
Line 109:                {
Line 110:                    _tjq_Users = CreateObjectSet<tjq_Users>();
Line 111:                }
Line 112:                return _tjq_Users;


Source File: D:\Projects\NopCommerce\from client\test\Source\Libraries\Nop.BusinessLogic\Data\NopObjectContext.cs    Line: 110


Mapping and metadata information could not be found for EntityType 'NopSolutions.NopCommerce.BusinessLogic.tjq_UsersManagement.tjq_Users'.


Thanks in Advance
Khem
13 年 前
Hi Experts,
I am regular user of NopCommerce but mostly i was working in previous  version <1.7. But now i started nopCommerce 1.7 in 2010 VS.

1.
I added one table called :
tjq_users actually this was in my previous e-commerce.

Having Field Like:

public partial class tjq_Users : BaseEntity
    {
        public tjq_Users()
        {
        }
        public int UserID { get; set; }
        public int UserAccessLevel { get; set; }
        public DateTime UserDateStamp { get; set; }
        public bool UserValidated { get; set; }
        public DateTime UserLastAccessDate { get; set; }
        public bool UserActive { get; set; }
        public DateTime UserExpirationDate { get; set; }
        public bool UserNews { get; set; }
        public bool UserMailingList { get; set; }
        public DateTime UserSubscribeDate { get; set; }
        public DateTime UserSubscribeCancelDate { get; set; }
        public string UserSubscriptionDescription { get; set; }
        public int UserSubscriptionTerm = 1;
        public float UserMonthlyRate { get; set; }
        public DateTime UserNextChargeDate { get; set; }
        public float UserNextChargeAmount { get; set; }
      
        public string UserEmailAddress { get; set; }
        public string UserFirstName { get; set; }
        public string UserLastName { get; set; }
        public string UserPassword { get; set; }
        public bool UserNotifyForumPostAll{get;set;}
        public bool UserNotifyNews{get;set;}
        public bool UserNotifyForumPostRelated{get;set;}
        public bool UserNotifyBlogPost { get; set; }
        public string UserNickName { get; set; }
        public string UserReferralAffiliateID { get; set; }
        public int UserReferralUserID { get; set; }
        
     }
Its because i just want to store user information in both system from NopCommerce registration Form.

2. I did pull in the NopModel.edmx.
3. get inside of NopObjectContext.css and added following code:
  public ObjectSet<tjq_Users> tjq_Users
        {
            get
            {
                if ((_tjq_Users == null))
                {
                    _tjq_Users = CreateObjectSet<tjq_Users>();
                }
                return _tjq_Users;
            }

        }
        private ObjectSet<tjq_Users> _tjq_Users;
4.  I did call on CustomerManager.cs like below
var tjq = context.tjq_Users.CreateObject();

            tjq.UserID = 0;
            tjq.UserFirstName = "sunil";
            tjq.UserLastName = "paudel";
            tjq.UserEmailAddress = "[email protected]";
            tjq.UserPassword = "password";
            tjq.UserReferralAffiliateID = "aaaa";
            tjq.UserNotifyForumPostAll = true;
            tjq.UserNotifyNews = true;
            tjq.UserNotifyForumPostRelated = true;
            tjq.UserNotifyBlogPost = true;
            tjq.UserNickName = "test name";
            tjq.UserReferralUserID = 1;
            tjq.UserAccessLevel = 0;
            tjq.UserDateStamp = DateTime.Now;
            tjq.UserValidated = true;
            tjq.UserLastAccessDate = DateTime.Now;
            tjq.UserActive = true;
            tjq.UserExpirationDate = DateTime.Now.AddDays(300);
            tjq.UserNews = false;
            tjq.UserMailingList = false;
            tjq.UserSubscribeDate = DateTime.Now;
            tjq.UserSubscribeCancelDate = DateTime.Now.AddDays(300);
            tjq.UserSubscriptionDescription = "teest";
            tjq.UserSubscriptionTerm = 1;
            tjq.UserMonthlyRate = 1010;
            tjq.UserNextChargeDate = DateTime.Now.AddDays(300);
            tjq.UserNextChargeAmount = 100;
            context.tjq_Users.AddObject(tjq);
           context.SaveChanges();
5. Finally i get following error

Mapping and metadata information could not be found for EntityType 'NopSolutions.NopCommerce.BusinessLogic.tjq_UsersManagement.tjq_Users'.
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: Mapping and metadata information could not be found for EntityType 'NopSolutions.NopCommerce.BusinessLogic.tjq_UsersManagement.tjq_Users'.

Source Error:

Line 108:                if ((_tjq_Users == null))
Line 109:                {
Line 110:                    _tjq_Users = CreateObjectSet<tjq_Users>();
Line 111:                }
Line 112:                return _tjq_Users;


Source File: D:\Projects\NopCommerce\from client\test\Source\Libraries\Nop.BusinessLogic\Data\NopObjectContext.cs    Line: 110


Mapping and metadata information could not be found for EntityType 'NopSolutions.NopCommerce.BusinessLogic.tjq_UsersManagement.tjq_Users'.


Thanks in Advance
Khem
13 年 前
I too, am having the Mapping and metadata information could not be found for EntityType error pop up, not just for the Setting table but also for the Log table. Any help would be greatly appreciated. Thank you!
13 年 前
Please review the "how to" tutorial here.

HTH
13 年 前
Thanks for the reply but I checked everything and it is still throwing the same error.
13 年 前
I assume you have attempted to build the entire solution.

If you are getting that error then something is not right in your entity mappings.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.