Features The templates have the following features. Includes all tables, stored procedures, functions, and views with the ability to exclude objects based on regex patterns.
Ability to automatically remove object prefix and suffixes ie. Dbml file can still be customized with the normal Visual Studio designer. Dbml file can be refreshed based on the current database schema without losing customizations. Generates one file per entity instead of one massive file. Generated entity files are added to the project as code behind files to their corresponding custom entity files.
Generation of entity manager classes. Adds customizable business rules engine to enforce entity validation, business and security rules.
Provides access to common queries based on primary keys, foreign keys, and indexes. Common queries are exposed as IQueryable so they can be extended. All templates can be customized to meet your needs. Quick Start Use the following steps to get started using the Linq to Sql templates.
Create a new Class Library project in Visual Studio Add a new CodeSmith project file to the Visual Studio project. Figure 1 Add a new Output to the project file for the Dbml. Figure 2 Add another Output to the project file for the Entities. Figure 3 Optionally, Add an Output for the Managers.
Figure 4 Set the Sample. The templates update the project for you. Finally, Generate the Outputs. The file conforms to the Microsoft DbmlSchema. 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. Be aware that the template will drop tables, columns and associations that it did not find in the database.
Properties on the Dbml. Property Description CleanExpression List of regular expressions to clean table, view, column and procedure names. Any matched text found will be removed from the name. IgnoreList List of regular expressions used to ignore tables, views and procedures when generating mapping. Any database objects that match one of these regular expressions will be ignored. IncludeFunctions Include stored procedures and user functions in mapping.