Simple sample of ADO.NET Entity Framework model code generation

This is a simple template, print all entities and your properties.
<#@ template debug="True" language="C#"#>
<#@ assembly name="SFS.Model" #>
<#@ import namespace="SFS.Model" #> 
<#@ dom processor="SFSEdmxProcessor"  
requires="EntityModel='MyModel.edmx'"  #>
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version: 2.0.50727.1434 
//     Generate:        7/2/2008 10:45:11 PM
//     Author:          Emir
//     Comany:            
//     Email:            
//     Web site:          
//      			
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;

namespace MyWindowsApplication 
{
<#	foreach(EntityInfo entity in this.Model.Entities) {#>
	public partial class <#=entity.Name#>{
<#		foreach(PropertyInfo property in entity.Properties) {#>
		public <#=property.NetType #> <#=property.Name#> { get; set; }
<#		}#>
	}
<#	} #> 
}


And the next code is the automatic transformation
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version: 2.0.50727.1434 
//     Generate:        7/2/2008 10:45:11 PM
//     Author:          Emir
//     Comany:            
//     Email:            
//     Web site:          
//      			
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;

namespace MyWindowsApplication 
{
	public partial class AddressInfo{
		public Int32 AddressID { get; set; }
		public String AddressLine1 { get; set; }
		public String AddressLine2 { get; set; }
		public String City { get; set; }
		public String PostalCode { get; set; }
		public Guid rowguid { get; set; }
		public DateTime ModifiedDate { get; set; }
	}
	public partial class AddressTypeInfo{
		public Int32 AddressTypeID { get; set; }
		public String Name { get; set; }
		public Guid rowguid { get; set; }
		public DateTime ModifiedDate { get; set; }
	}
	public partial class ContactInfo{
		public Int32 ContactID { get; set; }
		public Boolean NameStyle { get; set; }
		public String Title { get; set; }
		public String FirstName { get; set; }
		public String MiddleName { get; set; }
		public String LastName { get; set; }
		public String Suffix { get; set; }
		public String EmailAddress { get; set; }
		public Int32 EmailPromotion { get; set; }
		public String Phone { get; set; }
		public String PasswordHash { get; set; }
		public String PasswordSalt { get; set; }
		public String AdditionalContactInfo { get; set; }
		public Guid rowguid { get; set; }
		public DateTime ModifiedDate { get; set; }
	}
	public partial class ContactTypeInfo{
		public Int32 ContactTypeID { get; set; }
		public String Name { get; set; }
		public DateTime ModifiedDate { get; set; }
	}
	public partial class CountryRegionInfo{
		public String CountryRegionCode { get; set; }
		public String Name { get; set; }
		public DateTime ModifiedDate { get; set; }
	}
	public partial class StateProvinceInfo{
		public Int32 StateProvinceID { get; set; }
		public String StateProvinceCode { get; set; }
		public Boolean IsOnlyStateProvinceFlag { get; set; }
		public String Name { get; set; }
		public Int32 TerritoryID { get; set; }
		public Guid rowguid { get; set; }
		public DateTime ModifiedDate { get; set; }
	}
 
}


See a next sample, generating business rules or the tutorial step by step

Last edited Jul 4, 2008 at 6:45 AM by emirtrevino, version 7

Comments

No comments yet.