<%@ Template Language="C#" TargetLanguage="C#" Debug="True" Encoding="UTF-8" %> <%@ Assembly Src="Model.cs" %> <%@ Assembly Src="Extensions.cs" %> <%@ Import Namespace="System.Collections.Generic" %> <%@ Import Namespace="System.Linq" %> <%@ Import Namespace="System.Text" %> <%@ Import Namespace="System.Text.RegularExpressions" %> <%@ Import Namespace="SchemaMapper" %> <%@ Property Name="Entity" Type="SchemaMapper.Entity" %> <%@ Property Name="ContextNamespace" Type="System.String" %> <%@ Property Name="EntityNamespace" Type="System.String" %> <%@ Property Name="MappingNamespace" Type="System.String" %> //------------------------------------------------------------------------------ // // This code was generated by a CodeSmith Template. // // DO NOT MODIFY contents of this file. Changes to this // file will be lost if the code is regenerated. // //------------------------------------------------------------------------------ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; namespace <%= MappingNamespace %> { public partial class <%= Entity.MappingName.ToSafeName() %> : System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<<%= EntityNamespace %>.<%= Entity.ClassName.ToSafeName() %>> { public <%= Entity.MappingName.ToSafeName() %>() { // table <% if (string.IsNullOrEmpty(Entity.TableSchema)) { %> ToTable("<%= Entity.TableName %>"); <% } else { %> ToTable("<%= Entity.TableName %>", "<%= Entity.TableSchema %>"); <% } %> // keys <% if (Entity.Properties.PrimaryKeys.Count() > 0) { %> HasKey(t => <%= KeyExpression(Entity.Properties.PrimaryKeys, "t") %>); <% } %> // Properties <% foreach(var p in Entity.Properties) { Response.Write(PropertyExpression(p)); } %> // Relationships <% foreach(var r in Entity.Relationships.Where(e => e.IsMapped)) { if (r.IsManyToMany) Response.Write(ManyToManyExpression(r)); else Response.Write(RelationshipExpression(r)); } %> } } }