<#@ template language="C#" debug="True" hostSpecific="True" #> <#@ output extension=".generated.cs" #> <#@ include file="$(LinqToDBT4MySqlTemplatesDirectory)LinqToDB.MySql.Tools.ttinclude" #> <#@ include file="$(LinqToDBT4MySqlTemplatesDirectory)PluralizationService.ttinclude" #> <# //@ include file="$(ProjectDir)LinqToDB.Templates\LinqToDB.MySql.Tools.ttinclude" #> <# //@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude" #> <# /* 1. Create new *.tt file (e.g. MyDatabase.tt) in a folder where you would like to generate your data model and copy content from this file to it. For example: MyProject DataModels MyDatabase.tt 2. Modify the connection settings below to connect to your database. 3. Add connection string to the web/app.config file: 4. To access your database use the following code: using (var db = new MyDatabaseDB()) { var q = from c in db.Customers select c; foreach (var c in q) Console.WriteLine(c.ContactName); } 5. See more at https://linq2db.github.io/articles/T4.html IMPORTANT: if running .tt file gives you error like this: "error : Failed to resolve include text for file: C:\...\$(LinqToDBT4TemplatesDirectory)LinqToDB..Tools.ttinclude" check tt file properties. Custom tool must be set to TextTemplatingFileGenerator, not TextTemplatingFilePreprocessor or any other value. */ NamespaceName = "DataModels"; // to configure GetSchemaOptions properties, add them here, before load metadata call LoadMySqlMetadata("srvbo", "UserDatabase", "UserDbAdmin", "12345678"); // LoadMySqlMetadata(string connectionString); // to adjust loaded database model before generation, add your code here, after load metadata, but before GenerateModel() call GenerateModel(); #>