UseLazyLoadingProxies

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
hello every body.
i have this error :

Navigation property 'DoctorRegistration' on entity type 'Customer' is not virtual. UseLazyLoadingProxies
requires all entity types to be public, unsealed, have virtual navigation properties, and have a public or
protected constructor.


i have written 'DoctorRegistration' exactly like 'Address' .

anywhere in code that have 'virtual' for address , i use virtual for DoctorRegistration too!
what should i do?
4 years ago
I have Same problem.

System.InvalidOperationException: Navigation property 'Addresses' on entity type 'Customer' is not virtual. UseLazyLoadingProxies requires all entity types to be public, unsealed, have virtual navigation properties, and have a public or protected constructor.
4 years ago
you should check All Values which you are inserting .
some one of that value is not match with your database datatype.
4 years ago
fridaHakimi wrote:
you should check All Values which you are inserting .
some one of that value is not match with your database datatype.


Thanks, but my error occurs when I add this lines
modelBuilder.ApplyConfiguration(new Nop.Data.Mapping.Customers.RewardPointsHistoryMap());
modelBuilder.ApplyConfiguration(new Nop.Data.Mapping.Orders.OrderMap());  


to the OnModelCreating of my DbContext
4 years ago
fridaHakimi wrote:
hello every body.
i have this error :

Navigation property 'DoctorRegistration' on entity type 'Customer' is not virtual. UseLazyLoadingProxies
requires all entity types to be public, unsealed, have virtual navigation properties, and have a public or
protected constructor.


i have written 'DoctorRegistration' exactly like 'Address' .

anywhere in code that have 'virtual' for address , i use virtual for DoctorRegistration too!
what should i do?


I'm facing the same problem, looked everywhere but I can't find any solution.
4 years ago
I have the same problem.

I am getting following error while mapping the my entity with an existing product entity

{"Navigation property 'Addresses' on entity type 'Customer' is not virtual. UseLazyLoadingProxies requires all entity types to be public, unsealed, have virtual navigation properties, and have a public or protected constructor."}

I want use the existing product id as a foreign key in my table but getting error.
My code is :
public class ProductPackageMap : NopEntityTypeConfiguration<ProductPackage>
    {
        public override void Configure(EntityTypeBuilder<ProductPackage> builder)
        {
          
            builder.ToTable(nameof(ProductPackage));
            builder.HasKey(point => point.Id);

            builder.HasOne(subscription => subscription.Product)
              .WithMany()
              .HasForeignKey(subscription => subscription.ProductId)
              .IsRequired();

        }
    }


please help. your help will be helpful for many people.
4 years ago
You can not link new tables in plugins to existing tables in nopCommerce because they are in different contexts. This is a limitation of Entity Framework
There are a few posts about it -
https://docs.nopcommerce.com/developer/plugins/plugin-with-data-access.html
https://www.nopcommerce.com/boards/topic/55498/add-table-with-references-to-existing-entities
4 years ago
Yidna wrote:
You can not link new tables in plugins to existing tables in nopCommerce because they are in different contexts. This is a limitation of Entity Framework
There are a few posts about it -
https://docs.nopcommerce.com/developer/plugins/plugin-with-data-access.html
https://www.nopcommerce.com/boards/topic/55498/add-table-with-references-to-existing-entities


So do you suggest any tricky way to join two tables ? (one from context of our plugin and another from nopCommerce context)
4 years ago
You can still access the data in other tables just not use those techniques
If you store ProductId in your new table use that Id in the normal places you would i.e. _productService.GetProductById(newtable.ProductId);
Linq queries are a bit more complicated or
Do the joins in SQL and use the output of Store Procedure calls back in code
4 years ago
Yidna wrote:
Do the joins in SQL and use the output of Store Procedure calls back in code


I think that's the best idea right now.
Thanks dear Yidna
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.