How to create Database Tables?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 11 años
I am reading how to develop Plugins for nopCommerce: https://www.nopcommerce.com/docs/75/plugin-with-data-access.aspx and there is code like that:

namespace Nop.Plugin.Other.ProductViewTracker.Data
{
    public class TrackingRecordMap : EntityTypeConfiguration<TrackingRecord>
    {
        public TrackingRecordMap()
        {
            ToTable("ProductViewTracking");

            //Map the primary key
            HasKey(m => m.Id);
            //Map the additional properties
            Property(m => m.ProductId);
            //Avoiding truncation/failure
            //so we set the same max length used in the product tame
            Property(m => m.ProductName).HasMaxLength(400);
            Property(m => m.IpAddress);
            Property(m => m.CustomerId);
            Property(m => m.IsRegistered);
        }
    }
}

I wonder if we need to create the mapped database table manually or it is done for us automatically in RecordObjectContext within the following methods?

public string CreateDatabaseInstallationScript()
{
    return ((IObjectContextAdapter)this).ObjectContext.CreateDatabaseScript();
}
public void Install()
{
     Database.SetInitializer<TrackingRecordObjectContext>(null);
     Database.ExecuteSqlCommand(CreateDatabaseInstallationScript());
     SaveChanges();
}

I couldn't see what calls
Install()
method and where?
Hace 11 años
I've found what calls Install(). BasePlugin has its own virtual Install() method and we call Install method from within BasePlugin.Install() method.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.