Inhalte aufrufen

Profilbild

Add additional tables and fields in existing database

custometable dataflow datafetch architectureunderstanding customizedb

  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
1 Antwort zu diesem Thema

#1 pratiksha12

pratiksha12

    Newbie

  • Members
  • Punkt
  • 5 Beiträge

Geschrieben: 16 April 2016 - 07:43

hello 

 

As i want to customize tables of smartstore database and want to add additional fields and tables.

 

so can anyone highlight me on how the data flow is going and how architecture is set and what i will have to do in order to achieve my gole.



#2 nickh

nickh

    Erfahrener Benutzer

  • Members
  • 129 Beiträge

Geschrieben: 16 April 2016 - 16:46

Hi,

 

SmartStore uses Entity Framework for database communication.  To add columns to an existing table, you need to find the domain class for the table you want in SmartStore.Core.Domain.Common.  For example, if you wanted to add another address field (e.g. Address Line 3), you would add the following to the Address class:

 

[DataMember]
public string Address3 { get; set; }
 
Once you've done this, you need to create an Entity Framework migration, by running the following from the Nuget console in Visual Studio:
 
add-migration [Name_of_your_migration]
 
The final step is to tell Entity Framework to update your database with your new migration.  To do this you simply run the following from the Nuget console:
 
update-database
 
This will create the new column on the Address table, and add a line into the _MigrationHistory table (which is what Entity Framework uses to manage migrations).

  • pratiksha12 gefällt das