This is a migrated thread and some comments may be shown as answers.
Add new cloumn in databse using forward mapping
5 Answers 33 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ratndeep
Top achievements
Rank 1
Ratndeep asked on 30 Nov 2009, 08:59 AM
I am new to OpenAccess and using forward mapping in my project.
i have this class declared in Model :

 [Persistent(IdentityField = "id")]
    public class Currency : Entity
    {
        /********************************************************************
         * Database Fields
         * ******************************************************************/
        #region Database Fields
        private string code;
        private string symbol;
        #endregion

        /********************************************************************
         * Properties
         * ******************************************************************/
        #region Properties
        [FieldAlias("code")]
        public string Code
        {
            get { return code; }
            set { code = value; }
        }

        [FieldAlias("symbol")]
        public string Symbol
        {
            get { return symbol; }
            set { symbol = value; }
        }
}
Now  i want to  add two more properties here named currencyName and result . So how should i do it here so this column is also created in database side.

Thanks in advance..

5 Answers, 1 is accepted

Sort by
0
Accepted
IT-Als
Top achievements
Rank 1
answered on 30 Nov 2009, 11:40 AM
Hi Ratndeep,

You just add the corresponding fields (private....) and your public properties for reading/writing those fields and rebuild your project. This naturally assumes that you have the UpdateDatabase property on your project (see project properties) set to True.
OpenAccess will then migrate your existing schema to the new one (eg. add two new columns in the table)

You can use the Forward Mapping dialog (in the Telerik menu within Visual Studio) to define the column names and other properties if you want to.

Regards

Henrik
0
Ratndeep
Top achievements
Rank 1
answered on 30 Nov 2009, 12:40 PM
Thanks Henrik for this.
Could u tell me how to declare a foriegn key in openAccess.
0
IT-Als
Top achievements
Rank 1
answered on 30 Nov 2009, 12:46 PM
Hi,

In the Forward mapping dialog, when you select a field in your persistent class there is a region called "Generate SQL foreign key constraint" that can be used for that purpose.

Regards

Henrik
0
Ratndeep
Top achievements
Rank 1
answered on 30 Nov 2009, 01:08 PM
Hi Henrik,

There is a no option of "Generate SQL foreign key constraint" .I am using Telerik OpenAccess ORM 2009.3
0
IT-Als
Top achievements
Rank 1
answered on 30 Nov 2009, 01:17 PM
Hi again,

Oh sorry... Naturally this is only enabled if you have a reference to another persistent class or a list of persistent classes... like in the Order-OrderLine relationship for example. Then the foreign key constraint will be placed on the fk_orderid column in the OrderLine table, because that field denotes which OrderLine belongs to what Order. Please note that the Order-OrderLine is only mentioned as an example.

Regards

Henrik
Tags
General Discussions
Asked by
Ratndeep
Top achievements
Rank 1
Answers by
IT-Als
Top achievements
Rank 1
Ratndeep
Top achievements
Rank 1
Share this question
or