|
Getting Started [This guide belongs to the older version of ActiveWriter and will be updated.] This document replicates the Getting Started document of ActiveRecord using ActiveWriter. It is assumed that you have completed instructions on that document, since some parts are omitted here. Adding a model file to your project
Enabling ActiveWriter code generation
As soon as you change the custom tool of a project item in Visual Studio, given custom tool automatically runs against your document. ActiveWriter generates code for domain models using a custom tool class called ActiveWriterCodeGenerator. The securitiy warning is the standart warning dialog of the text templating engine of DSL Tools, which is used to create ActiveWriter.
At this stage, code is generated for the model an placed in Blog.cs file as a sub-item of the model file. Since there are no entity (or class) modelled on the modelling surface, .cs file will be nearly empty. One thing to note is that, the namespace is defined by the project environment and used as is in ActiveWriter generated code. Rgiht now, there's no option to change the namespace through the editor.
Adding model classes using Server Explorer
When you drop table or tables to the model, ActiveWriter walks the Server Explorer hierarchy to extract some information. During this process, there may be somewhat annoying flicker in Server Explorer window. This is normal, and ActiveWriter will behave more screen friendly in the future. This behaviour is more evident if there's a connection with many tables, placed above the dropped tables' connection in Solution Explorer. After the walk, ActiveWriter then connects to the model database through the connection already defined in Server Explorer. It gathers necessary information on columns, keys and foreign key relations to construct the model. ActiveWriter does not cache this information, so it will connect again if you drop another table to the model later. Examining model and changing properties
Note that, although post_blogid is a column in Posts table in the database, ActiveRecord did not add it to the class. Since this column is the relation between two classes, ActiveWriter used the column in many to one relation instead. If you save the model right now, ActiveWriter will regenerate code, including two new classes decorated with ActiveRecord attributes. |