...
The Dbml.cst template is used to create a LINQ to SQL dbml file. The file conforms to the Microsoft DbmlSchema.xsd schema. This is the same document that the LINQ to SQL designer uses. The generated dbml file from this template can also be edited from the LINQ to SQL designer.
The template will create a new file if it doesn't exist. If the file does exist, the template will read it in and update it. This allows you to make changes to the file and not have it overwrite if the template is re-ran. However, only some of the attributes are safe from overwriting. Here is a list of safe attributes. They will be listed as an xpath.
Safe Attributes to change in the Dbml file ...
- Database/@Class - The name of the DataContext class that will be generated.
- Database/@EntityNamespace - The namespace for the entity classes.
- Database/@ContextNamespace - The namespace for the DataContext class.
- Table/@Member - The property name for the table in the DataContext class.
- Type/@Name - The name of the entity class.
- Column/@Member - The property name for the column in the entity class.
- Column/@Storage - The private field LINQ to SQL will us to assign values to.
- Association/@Member - The property name for this association.
- Association/@Storage - The private field LINQ to SQL will us to assign values the association to.
- Association/@DeleteOnNull - Deletes row when association is set to null. Value will not be persisted if the CST's IncludeDeleteOnNull Property is set to false.
- Function/@Method - The name of the method for the database procedure.
- Parameter/@Parameter - The method argument name that maps to the database procedure parameter.
Warning: Be aware that the template will drop tables, columns and associations that it did not find in the database.
Properties on the Dbml.cst template:
Info |
---|
The EnumList, IgnoreList and IncludeList properties use a list of Regular Expressions that match the the full name of a Table, View, Command. Here is a common Regex pattern that will match a table by name (E.G., ^owner.TableName$). For Example, the following regex (^dbo.Account$) will match the Account table. We recommend using Expresso to build your regular expression lists. |
Property | Description |
---|---|
1.Database |
|
CleanExpression | List of regular expressions to clean table, view, column and procedure names. Any matched text found will be removed from the name. |
EnumList | List of regular expressions to identify an Enum Table. |
IgnoreList | List of regular expressions used to ignore tables, views and procedures when generating mapping. |
IncludeList | List of regular expressions used to include tables, views and procedures when generating mapping. When this property is set the IgnoreList property will be ignored and only tables included in this list will be used. |
IncludeFunctions | Include stored procedures and user functions in mapping. |
IncludeViews | Include views in mapping. |
SourceDatabase | The source database to generate the dbml file for. |
2.Class |
|
ContextNamespace | The namespace to use for the context class file. |
EntityBase | The base class for the entity. |
EntityNamespace | The namespace to use for the entity class files. |
IncludeDeleteOnNull | Templates will generated DeleteOnNull Attribute for Associations. |
Naming Conventions | A Menu of options for naming objects in the dbml. |
AssociationNaming | Add a list suffix or pluralize associations to an object. |
EntityNaming | Generate entity objects in singular or plural form. |
TableNaming | The table naming convention followed in the source database. |
3.Enum |
|
NameColumn | List of regular expressions to identify an Enum Table's Name Column. |
DescriptionColumm | List of regular expressions to identify an Enum Table's Description Column. |
4.Mapping |
|
DbmlFile | The path to the dbml file to generate. |