If you know how to decorate a class with rapid attributes by hand without the class being generated from a database schema. You are practicing class first design. Meaning you will be hand coding entity classes and its mapping. After hard coding entity mapping, you may want to create a database schema for the hand coded entities.

Rapid entity framework enable you to extract your hand coded entities into your database using the rapid visual studio designer. We will be providing options to extract the schema details into an sql file (Future plans). Now how do we hand code and export these classes into datastore?

Sample Hand coded class

    [Entity("Categories")]
    public partial class Category {
        
        private string categoryname;
        
        private string description;
        
        private byte[] picture;
        
        private int categoryid;
        
        private IList products;
        
        [Field("CategoryName")]
        public virtual string CategoryName {
            get {
                return categoryname;
            }
            set {
                this.categoryname = value;
            }
        }
        
        [Field("Description")]
        public virtual string Description {
            get {
                return description;
            }
            set {
                this.description = value;
            }
        }
        
        [Field("Picture")]
        public virtual byte[] Picture {
            get {
                return picture;
            }
            set {
                this.picture = value;
            }
        }
        
        [Key("CategoryID", AutoKey=true)]
        public virtual int CategoryID {
            get {
                return categoryid;
            }
            set {
                this.categoryid = value;
            }
        }
        
        [OneToMany(typeof(Product), RelationColumn = "CategoryID")]
        public virtual IList Products {
            get {
                return products;
            }
            set {
                this.products = value;
            }
        }
    }

The above class code is a meta structure of a Category class which we would love to export into our database since its a class first design and it does not exist in the database yet. Now, how do we go about it :
  1. Drag your class from solution explorer onto the designer surface
classfirst.JPG

2. Your dragged classes becomes a rapid artifact on the designer surface like so :

draggedclass.JPG

3. You will right click on the designer surface, or on the dragged class to click on the option export to database. New release will include an option to export into a .sql file.

exportoption.JPG

Note* You may be wondering which database will the export to database operation do the updates on, well you guessed right. You can set your designer properties to point to the database you want. At Present, we support the following database providers Supported Database Providers

1. Selecting which database to export on the designer property sheet. :
designerproperties.JPG

once you click on the ellipses on the connection string property of the designer, the visual studio choose data source dialog will pop up, and here you can configure the connection string to export to. Also note that when you drag from server explorer, your drag operation will update the designer connection string to the data source you are draging from . (We are looking into efficient ways. We need your ideas)

[image:datasourcepopup.JPG]

watch out on this area, we will be providing more detailed information on this arena.

Last edited Feb 23, 2010 at 3:07 PM by ahmedsalako, version 11

Comments

No comments yet.