lxl 2 سال پیش
والد
کامیت
94b18df516

+ 1 - 1
.gitignore

@@ -88,7 +88,6 @@ StyleCopReport.xml
 *.tmp
 *.tmp_proj
 *_wpftmp.csproj
-*.log
 *.vspscc
 *.vssscc
 .builds
@@ -361,3 +360,4 @@ MigrationBackup/
 FodyWeavers.xsd
 /EMIS.Web/Logs
 /EMIS.Web/Content/DownFile/2022-09-19
+/EMIS.Web/App_Data/SenparcTraceLog

+ 20 - 0
EMIS.Entities.Log/App.config

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <configSections>
+    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
+    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+  </configSections>
+  <entityFramework>
+    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
+      <parameters>
+        <parameter value="v11.0" />
+      </parameters>
+    </defaultConnectionFactory>
+    <providers>
+      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
+    </providers>
+  </entityFramework>
+  <connectionStrings>
+    <add name="EMISNewLogContext" connectionString="metadata=res://*/EMISLogContext.csdl|res://*/EMISLogContext.ssdl|res://*/EMISLogContext.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=192.168.0.29\sql2008;initial catalog=EMISNewLog;persist security info=True;user id=sa;password=1;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
+  </connectionStrings>
+</configuration>

+ 55 - 0
EMIS.Entities.Log/EMIS.Entities.Log.Context.cs

@@ -0,0 +1,55 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated from a template.
+//
+//    Manual changes to this file may cause unexpected behavior in your application.
+//    Manual changes to this file will be overwritten if the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+#pragma warning disable 1573
+namespace EMIS.Entities.Log
+{
+    using System;
+    using System.Data.Common;
+    using System.Data.Entity;
+    using System.Data.Entity.Infrastructure;
+    using EntityFramework.Extensions;
+    using System.Linq.Expressions;
+    using System.Data.Entity.Core.Objects;
+    
+    public partial class EMISNewLogContext : DbContext
+    {
+        static EMISNewLogContext()
+    	{ 
+    		Database.SetInitializer<EMISNewLogContext>(null);
+    	}
+    	
+    	public EMISNewLogContext() : base("name=EMISNewLogContext") {
+            var objectContext = (this as IObjectContextAdapter).ObjectContext;
+    
+            objectContext.CommandTimeout = 12000;
+            base.Configuration.ProxyCreationEnabled = false;
+        }
+        public EMISNewLogContext(string nameOrConnectionString) : base(nameOrConnectionString) {
+            var objectContext = (this as IObjectContextAdapter).ObjectContext;
+    
+            objectContext.CommandTimeout = 12000;
+            base.Configuration.ProxyCreationEnabled = false;
+        }
+        protected void Delete<TEntity>(Expression<Func<TEntity, bool>> whereExpression) where TEntity : class
+        {
+            var context = ((IObjectContextAdapter)this).ObjectContext;
+            IObjectSet<TEntity> source = context.CreateObjectSet<TEntity>();
+            source.Delete(whereExpression);
+        }
+        protected override void OnModelCreating(DbModelBuilder modelBuilder)
+        {
+    		modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
+    		modelBuilder.Configurations.Add(new Log_Operate_Mapping());
+    		modelBuilder.Configurations.Add(new VW_Sys_User_Mapping());
+        }
+    	
+        public DbSet<Log_Operate> Log_Operate { get; set; }
+        public DbSet<VW_Sys_User> VW_Sys_User { get; set; }
+    }
+}

+ 210 - 0
EMIS.Entities.Log/EMIS.Entities.Log.Context.tt

@@ -0,0 +1,210 @@
+<#@ template language="C#" debug="false" hostspecific="true"#>
+<#@ include file="EF.Utility.CS.ttinclude"#><#@
+ output extension=".cs"#><#
+
+var loader = new MetadataLoader(this);
+var region = new CodeRegion(this);
+var inputFile = @"EMISLogContext.edmx";
+var ItemCollection = loader.CreateEdmItemCollection(inputFile);
+
+Code = new CodeGenerationTools(this);
+EFTools = new MetadataTools(this);
+ObjectNamespace = Code.VsNamespaceSuggestion();
+ModelNamespace = loader.GetModelNamespace(inputFile);
+
+EntityContainer container = ItemCollection.GetItems<EntityContainer>().FirstOrDefault();
+if (container == null)
+{
+    return string.Empty;
+}
+#>
+//------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated from a template.
+//
+//    Manual changes to this file may cause unexpected behavior in your application.
+//    Manual changes to this file will be overwritten if the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+#pragma warning disable 1573
+<#
+
+if (!String.IsNullOrEmpty(ObjectNamespace))
+{
+#>
+namespace <#=Code.EscapeNamespace(ObjectNamespace)#>
+{
+<#
+    PushIndent(CodeRegion.GetIndent(1));
+}
+
+#>
+using System;
+using System.Data.Common;
+using System.Data.Entity;
+using System.Data.Entity.Infrastructure;
+using EntityFramework.Extensions;
+using System.Linq.Expressions;
+using System.Data.Entity.Core.Objects;
+<#
+if (container.FunctionImports.Any())
+{
+#>
+using System.Data.Objects;
+<#
+}
+#>
+
+<#=Accessibility.ForType(container)#> partial class <#=Code.Escape(container)#> : DbContext
+{
+    static <#=Code.Escape(container)#>()
+	{ 
+		Database.SetInitializer<<#=Code.Escape(container)#>>(null);
+	}
+	
+	public <#=Code.Escape(container)#>() : base("name=<#=container.Name#>") {
+        var objectContext = (this as IObjectContextAdapter).ObjectContext;
+
+        objectContext.CommandTimeout = 12000;
+        base.Configuration.ProxyCreationEnabled = false;
+    }
+    public <#=Code.Escape(container)#>(string nameOrConnectionString) : base(nameOrConnectionString) {
+        var objectContext = (this as IObjectContextAdapter).ObjectContext;
+
+        objectContext.CommandTimeout = 12000;
+        base.Configuration.ProxyCreationEnabled = false;
+    }
+    protected void Delete<TEntity>(Expression<Func<TEntity, bool>> whereExpression) where TEntity : class
+    {
+        var context = ((IObjectContextAdapter)this).ObjectContext;
+        IObjectSet<TEntity> source = context.CreateObjectSet<TEntity>();
+        source.Delete(whereExpression);
+    }
+    protected override void OnModelCreating(DbModelBuilder modelBuilder)
+    {
+		modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
+<# 
+    foreach (EntityType entitySet in ItemCollection.GetItems<EntityType>().OrderBy(e => e.Name))
+    {
+#>
+		modelBuilder.Configurations.Add(new <#=Code.Escape(entitySet.Name)#>_Mapping());
+<#
+    }
+#>
+    }
+	
+<#
+    foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
+    {
+#>
+    <#=Accessibility.ForReadOnlyProperty(entitySet)#> DbSet<<#=Code.Escape(entitySet.ElementType)#>> <#=Code.Escape(entitySet)#> { get; set; }
+<#
+    }
+
+    foreach (var edmFunction in container.FunctionImports)
+    {
+        WriteFunctionImport(edmFunction, false);
+    }
+#>
+}
+<#
+
+if (!String.IsNullOrEmpty(ObjectNamespace))
+{
+    PopIndent();
+#>
+}
+<#
+}
+#>
+<#+
+string ModelNamespace { get; set; }
+string ObjectNamespace { get; set; }
+CodeGenerationTools Code { get; set; }
+MetadataTools EFTools { get; set; }
+
+void WriteLazyLoadingEnabled(EntityContainer container)
+{
+   string lazyLoadingAttributeValue = null;
+   var lazyLoadingAttributeName = MetadataConstants.EDM_ANNOTATION_09_02 + ":LazyLoadingEnabled";
+   if(MetadataTools.TryGetStringMetadataPropertySetting(container, lazyLoadingAttributeName, out lazyLoadingAttributeValue))
+   {
+       bool isLazyLoading;
+       if(bool.TryParse(lazyLoadingAttributeValue, out isLazyLoading) && !isLazyLoading)
+       {
+#>
+        this.Configuration.LazyLoadingEnabled = false;
+<#+
+       }
+   }
+}
+
+void WriteFunctionImport(EdmFunction edmFunction, bool includeMergeOption)
+{
+    var parameters = FunctionImportParameter.Create(edmFunction.Parameters, Code, EFTools);
+    var paramList = String.Join(", ", parameters.Select(p => p.FunctionParameterType + " " + p.FunctionParameterName).ToArray());
+    var returnType = edmFunction.ReturnParameter == null ? null : EFTools.GetElementType(edmFunction.ReturnParameter.TypeUsage);
+    var processedReturn = returnType == null ? "int" : "ObjectResult<" + MultiSchemaEscape(returnType) + ">";
+
+    if (includeMergeOption)
+    {
+        paramList = Code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
+    }
+#>
+
+    <#=AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction))#> <#=processedReturn#> <#=Code.Escape(edmFunction)#>(<#=paramList#>)
+    {
+<#+
+        if(returnType != null && (returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType ||
+                                  returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.ComplexType))
+        {
+#>
+        ((IObjectContextAdapter)this).ObjectContext.MetadataWorkspace.LoadFromAssembly(typeof(<#=MultiSchemaEscape(returnType)#>).Assembly);
+
+<#+
+        }
+
+        foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
+        {
+            var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
+            var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
+            var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + parameter.RawClrTypeName + "))";
+#>
+        var <#=parameter.LocalVariableName#> = <#=isNotNull#> ?
+            <#=notNullInit#> :
+            <#=nullInit#>;
+
+<#+
+        }
+
+        var genericArg = returnType == null ? "" : "<" + MultiSchemaEscape(returnType) + ">";
+        var callParams = Code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
+
+        if (includeMergeOption)
+        {
+            callParams = ", mergeOption" + callParams;
+        }
+#>
+        return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<#=genericArg#>("<#=edmFunction.Name#>"<#=callParams#>);
+    }
+<#+
+    if(!includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType)
+    {
+        WriteFunctionImport(edmFunction, true);
+    }
+}
+
+string AccessibilityAndVirtual(string accessibility)
+{
+    return accessibility + (accessibility != "private" ? " virtual" : "");
+}
+
+string MultiSchemaEscape(TypeUsage usage)
+{
+    var type = usage.EdmType as StructuralType;
+    return type != null && type.NamespaceName != ModelNamespace ?
+        Code.CreateFullName(Code.EscapeNamespace(type.NamespaceName), Code.Escape(type)) :
+        Code.Escape(usage);
+}
+
+#>

+ 10 - 0
EMIS.Entities.Log/EMIS.Entities.Log.Mapping.cs

@@ -0,0 +1,10 @@
+
+//------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated from a template.
+//
+//    Manual changes to this file may cause unexpected behavior in your application.
+//    Manual changes to this file will be overwritten if the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+

+ 540 - 0
EMIS.Entities.Log/EMIS.Entities.Log.Mapping.tt

@@ -0,0 +1,540 @@
+<#@ template language="C#" debug="false" hostspecific="true"#>
+<#@ include file="EF.Utility.CS.ttinclude"#>
+<#@ assembly name="$(DevEnvDir)Microsoft.Data.Entity.Design.DatabaseGeneration.dll"#>
+<#@ import namespace="Microsoft.Data.Entity.Design.DatabaseGeneration" #>
+<#@ import namespace="System.Text"#>
+<#@ output extension=".cs"#><#
+CodeGenerationTools code = new CodeGenerationTools(this);
+CodeRegion region = new CodeRegion(this, 1);
+MetadataTools ef = new MetadataTools(this);
+string inputFile = @"EMISLogContext.edmx";
+
+var loadResult = LoadMetadata(inputFile);
+EdmItemCollection itemCollection = loadResult.EdmItems;
+var propertyToColumnMapping = loadResult.PropertyToColumnMapping;
+var manyToManyMappings = loadResult.ManyToManyMappings;
+var tphMappings = loadResult.TphMappings;
+string namespaceName = code.VsNamespaceSuggestion();
+string mapClassSuffix = "_Mapping";
+EntityFrameworkTemplateFileManager fileManager = EntityFrameworkTemplateFileManager.Create(this);
+WriteHeader(fileManager);
+
+foreach (EntityType entity in itemCollection.GetItems<EntityType>().OrderBy(e => e.Name))
+{
+    fileManager.StartNewFile(entity.Name + mapClassSuffix + ".cs");
+    BeginNamespace(namespaceName, code);	
+#>
+#pragma warning disable 1573
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Data.Common;
+using System.Data.Entity;
+using System.Data.Entity.ModelConfiguration;
+using System.Data.Entity.Infrastructure;
+using System.ComponentModel.DataAnnotations.Schema;
+
+internal partial class <#=code.Escape(entity) + mapClassSuffix#><#=string.Format(" : EntityTypeConfiguration<{0}>", code.Escape(entity))#>
+{
+    public <#=code.Escape(entity) + mapClassSuffix#>()
+    {					
+<# 	
+	string hasKey;
+	if(entity.KeyMembers.Count<EdmMember>() == 1)
+		hasKey = string.Format(".HasKey(t => t.{0})", entity.KeyMembers[0].Name);
+   	else
+		hasKey = string.Format(".HasKey(t => new {{{0}}})", string.Join(", ", entity.KeyMembers.Select(m => "t." + m.Name)));
+			
+					
+#>
+		this<#=hasKey#>;		
+<#
+	if(tphMappings.Keys.Contains(entity))
+	{
+		foreach(KeyValuePair<EntityType, Dictionary<EdmProperty, string>> entityMapping in tphMappings[entity])
+		{
+#>
+		this.Map<<#=entityMapping.Key.Name #>>(m =>
+		{
+		<#
+		foreach(KeyValuePair<EdmProperty, string> propertyMapping in entityMapping.Value)
+		{
+			string val;
+			switch(propertyMapping.Key.TypeUsage.EdmType.BaseType.FullName)
+			{
+				case "Edm.String":
+					val="\""+propertyMapping.Value+"\"";
+					break;
+				default:
+					val=propertyMapping.Value;
+					break;
+			}
+			
+		#>	m.Requires("<#=propertyMapping.Key.Name#>").HasValue(<#=val#>);
+		<#
+		}
+		#>});
+<#
+		}
+	}
+	
+    var entityPropertyToColumnMapping = propertyToColumnMapping[entity];	
+#>
+		this.ToTable("<#=ToTable(entityPropertyToColumnMapping.Item1)#>");
+<# 
+	foreach (EdmProperty property in entity.Properties)
+    {
+		string generateOption = GetGenerationOption(property, entity);
+		string required = "";
+		string unicCode = "";
+		string fixedLength = "";
+		string maxLength = "";
+		PrimitiveType edmType = (PrimitiveType) property.TypeUsage.EdmType;
+		if(edmType.ClrEquivalentType == typeof(string) || edmType.ClrEquivalentType == typeof(byte[]))
+		{
+			if (!property.Nullable)
+                required = ".IsRequired()";            
+
+			Facet unicodeFacet = property.TypeUsage.Facets.SingleOrDefault(f => f.Name == "Unicode");
+			unicCode = unicodeFacet != null && unicodeFacet.Value != null && (!(bool)unicodeFacet.Value) ? ".IsUnicode(false)" : "";
+		
+			Facet fixedLengthFacet = property.TypeUsage.Facets.SingleOrDefault(f => f.Name == "FixedLength");
+			fixedLength = fixedLengthFacet != null && fixedLengthFacet.Value != null && ((bool)fixedLengthFacet.Value) ? ".IsFixedLength()" : "";
+		
+			Facet maxLengthFacet = property.TypeUsage.Facets.SingleOrDefault(f => f.Name == "MaxLength");
+			maxLength = (maxLengthFacet != null && maxLengthFacet.Value != null && !maxLengthFacet.IsUnbounded) ? string.Format(".HasMaxLength({0})", maxLengthFacet.Value) : "";
+		}
+		if(!entityPropertyToColumnMapping.Item2.Keys.Contains(property)) continue;
+    	string hasColumnName = string.Format(".HasColumnName(\"{0}\")", entityPropertyToColumnMapping.Item2[property].Name);
+#>
+		this.Property(t => t.<#= property.Name#>)<#=hasColumnName + generateOption + required + unicCode + fixedLength + maxLength #>;
+<# 
+    } 
+
+  	var navigationProperties = entity.NavigationProperties.Where(np => 
+			{
+				return ((np.DeclaringType == entity) && 
+					   ((AssociationType) np.RelationshipType).IsForeignKey) && 
+					   (((AssociationType) np.RelationshipType).ReferentialConstraints.Single<ReferentialConstraint>().ToRole == np.FromEndMember);
+			});
+	foreach(NavigationProperty navProperty in navigationProperties)
+	{
+		StringBuilder navPropBuilder = new StringBuilder();
+		NavigationProperty navPropertyBackReference = navProperty.ToEndMember.GetEntityType().NavigationProperties
+						.Where(npBack => npBack.RelationshipType == navProperty.RelationshipType && npBack != navProperty)
+						.Single();
+        AssociationType associationType = (AssociationType) navProperty.RelationshipType;
+        if (navProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.One)            
+            navPropBuilder.AppendFormat("this.HasRequired(t => t.{0})", code.Escape(navProperty));                            
+        else            
+            navPropBuilder.AppendFormat("this.HasOptional(t => t.{0})", code.Escape(navProperty));                
+        
+        if (navProperty.FromEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many)
+        {
+            navPropBuilder.AppendFormat(".WithMany(t => t.{0})", code.Escape(navPropertyBackReference));                
+            if (associationType.ReferentialConstraints.Single().ToProperties.Count == 1)                
+                navPropBuilder.AppendFormat(".HasForeignKey(d => d.{0})", associationType.ReferentialConstraints.Single().ToProperties.Single().Name);                    
+            else
+            	navPropBuilder.AppendFormat(".HasForeignKey(d => new {{{0}}})", string.Join(", ", associationType.ReferentialConstraints.Single().ToProperties.Select(p => "d." + p.Name)));                    
+        }
+        else
+        {
+            navPropBuilder.AppendFormat(".WithOptional(t => t.{0})", code.Escape(navPropertyBackReference));                
+        }
+#>
+		<#= navPropBuilder.ToString() #>;
+<# 
+		}
+		
+		var manyToMany = entity.NavigationProperties.Where(np =>
+				np.DeclaringType == entity 
+				&& np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many 
+				&& np.FromEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many 
+				&& np.RelationshipType.RelationshipEndMembers.First() == np.FromEndMember);
+		
+		var manyToManyBuilder = new StringBuilder();
+		
+		foreach (NavigationProperty navProperty in manyToMany)
+		{
+			var member = navProperty.ToEndMember.GetEntityType().NavigationProperties
+							.Single(nv => (nv.RelationshipType == navProperty.RelationshipType) && (nv != navProperty));
+			var relationshipType = (AssociationType) navProperty.RelationshipType;
+			Tuple<EntitySet, Dictionary<RelationshipEndMember, Dictionary<EdmMember, string>>> tuple; 
+			if(manyToManyMappings.TryGetValue(relationshipType, out tuple))
+			{
+				string middleTableName = this.ToTable(tuple.Item1);
+				
+				var leftType = (EntityType) navProperty.DeclaringType;
+				Dictionary<EdmMember, string> leftKeyMappings = tuple.Item2[navProperty.FromEndMember];
+				string leftColumns = string.Join(", ", leftType.KeyMembers.Select(m => "\"" + leftKeyMappings[m] + "\""));
+				
+				var rightType = (EntityType) member.DeclaringType;
+				Dictionary<EdmMember, string> rightKeyMappings = tuple.Item2[member.FromEndMember];
+				string rightColumns = string.Join(", ", rightType.KeyMembers.Select(m => "\"" + rightKeyMappings[m] + "\""));
+				
+#>
+		this.HasMany(t => t.<#= code.Escape(navProperty) #>).WithMany(t => t.<#= code.Escape(member) #>)
+			.Map(m => 
+			{
+				m.ToTable("<#= middleTableName #>");
+				m.MapLeftKey(<#= leftColumns #>);
+				m.MapRightKey(<#= rightColumns #>);
+			});
+<#
+			}
+		}
+#>
+	}
+}
+<#
+    EndNamespace(namespaceName);
+}
+#>
+
+<#
+
+if (!VerifyTypesAreCaseInsensitiveUnique(itemCollection))
+{
+    return "";
+}
+
+fileManager.Process();
+
+#>
+<#+
+string GetResourceString(string resourceName)
+{
+	if(_resourceManager2 == null)
+	{
+		_resourceManager2 = new System.Resources.ResourceManager("System.Data.Entity.Design", typeof(System.Data.Entity.Design.MetadataItemCollectionFactory).Assembly);
+	}
+	
+    return _resourceManager2.GetString(resourceName, null);
+}
+System.Resources.ResourceManager _resourceManager2;
+
+void WriteHeader(EntityFrameworkTemplateFileManager fileManager)
+{
+    fileManager.StartHeader();
+#>
+//------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated from a template.
+//
+//    Manual changes to this file may cause unexpected behavior in your application.
+//    Manual changes to this file will be overwritten if the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+<#+
+    fileManager.EndBlock();
+}
+
+void BeginNamespace(string namespaceName, CodeGenerationTools code)
+{
+    CodeRegion region = new CodeRegion(this);
+    if (!String.IsNullOrEmpty(namespaceName))
+    {
+#>
+namespace <#=code.EscapeNamespace(namespaceName)#>
+{
+<#+
+        PushIndent(CodeRegion.GetIndent(1));
+    }
+}
+
+
+void EndNamespace(string namespaceName)
+{
+    if (!String.IsNullOrEmpty(namespaceName))
+    {
+        PopIndent();
+#>
+}
+<#+
+    }
+}
+string ToTable(EntitySet entitySet)
+{
+	var toTable = entitySet.Name;
+	//string schema = entitySet.GetSchemaName();
+	//if(!string.IsNullOrWhiteSpace(schema) && schema != "dbo")	
+	//	toTable += "\", \"" + schema;
+	return toTable;
+}
+
+bool VerifyTypesAreCaseInsensitiveUnique(EdmItemCollection itemCollection)
+{
+    var alreadySeen = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
+    foreach(var type in itemCollection.GetItems<StructuralType>())
+    {
+        if (!(type is EntityType || type is ComplexType))
+        {
+            continue;
+        }
+
+        if (alreadySeen.ContainsKey(type.FullName))
+        {
+            Error(String.Format(CultureInfo.CurrentCulture, "This template does not support types that differ only by case, the types {0} are not supported", type.FullName));
+            return false;
+        }
+        else
+        {
+            alreadySeen.Add(type.FullName, true);
+        }
+    }
+
+    return true;
+}
+
+string GetGenerationOption(EdmProperty property, EntityType entity)
+{
+	string result = "";
+	bool isPk = entity.KeyMembers.Contains(property);
+	MetadataProperty storeGeneratedPatternProperty = null;
+	string storeGeneratedPatternPropertyValue = "None";
+	
+	if(property.MetadataProperties.TryGetValue(MetadataConsts.EDM_ANNOTATION_09_02 + ":StoreGeneratedPattern", false, out storeGeneratedPatternProperty))	
+		storeGeneratedPatternPropertyValue = storeGeneratedPatternProperty.Value.ToString();		
+	
+	PrimitiveType edmType = (PrimitiveType) property.TypeUsage.EdmType; 
+	if (storeGeneratedPatternPropertyValue == "Computed")
+	{
+	    result = ".HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed)";
+	}
+	else if ((edmType.ClrEquivalentType == typeof(int)) || (edmType.ClrEquivalentType == typeof(short)) || (edmType.ClrEquivalentType == typeof(long)))
+	{
+	    if (isPk && (storeGeneratedPatternPropertyValue != "Identity"))
+	        result = ".HasDatabaseGeneratedOption(DatabaseGeneratedOption.None)";
+	    else if ((!isPk || (entity.KeyMembers.Count > 1)) && (storeGeneratedPatternPropertyValue == "Identity"))
+	        result = ".HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)";
+	}	
+	return result;    
+}
+
+MetadataLoadResult LoadMetadata(string inputFile)
+{       
+	var loader = new MetadataLoader(this);
+	bool loaded = false;
+	EdmItemCollection edmItemCollection = loader.CreateEdmItemCollection(inputFile);      
+	StoreItemCollection storeItemCollection = null;
+	if (loader.TryCreateStoreItemCollection(inputFile, out storeItemCollection))
+	{
+		StorageMappingItemCollection storageMappingItemCollection;
+		if (loader.TryCreateStorageMappingItemCollection(inputFile, edmItemCollection, storeItemCollection, out storageMappingItemCollection))
+			loaded = true;
+	}
+
+	if(loaded == false)
+		throw new Exception("Cannot load a metadata from the file " + inputFile);
+
+	var mappingMetadata = LoadMappingMetadata(inputFile);
+	var mappingNode		= mappingMetadata.Item1;
+	var nsmgr			= mappingMetadata.Item2;
+
+	var allEntitySets = storeItemCollection.GetAllEntitySets();		
+
+	return new MetadataLoadResult
+	       	{
+	       		EdmItems = edmItemCollection,
+	       		PropertyToColumnMapping = BuildEntityMappings(mappingNode, nsmgr, edmItemCollection.GetItems<EntityType>(), edmItemCollection.GetAllEntitySets(), allEntitySets),
+	       		ManyToManyMappings = BuildManyToManyMappings(mappingNode, nsmgr, edmItemCollection.GetAllAssociationSets(), allEntitySets),
+				TphMappings=BuildTPHMappings(mappingNode, nsmgr, edmItemCollection.GetItems<EntityType>(), edmItemCollection.GetAllEntitySets(), allEntitySets)
+	       	};
+}
+
+private Tuple<XmlNode, XmlNamespaceManager> LoadMappingMetadata(string inputFile)
+{
+	var xmlDoc = new XmlDocument();
+     xmlDoc.Load(Host.ResolvePath(inputFile));
+
+	 var schemaConstantsList = new SchemaConsts[]
+					{						
+						MetadataConsts.V2_SCHEMA_CONSTANTS,
+						MetadataConsts.V1_SCHEMA_CONSTANTS
+					};
+	foreach (var schemaConstants in schemaConstantsList)
+	{
+		var nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
+		nsmgr.AddNamespace("ef", schemaConstants.MslNamespace);
+		nsmgr.AddNamespace("edmx", schemaConstants.EdmxNamespace);
+		var mappingNode = xmlDoc.DocumentElement.SelectSingleNode("./*/edmx:Mappings", nsmgr);
+
+		if(mappingNode != null)
+			return Tuple.Create(mappingNode, nsmgr);
+	}     
+
+	throw new Exception(GetResourceString("Template_UnsupportedSchema"));
+}
+
+private Dictionary<EntityType, Dictionary<EntityType, Dictionary<EdmProperty, string>>> BuildTPHMappings(XmlNode mappingNode, XmlNamespaceManager nsmgr, IEnumerable<EntityType> entityTypes, IEnumerable<EntitySet> entitySets, IEnumerable<EntitySet> tableSets)
+{
+	var dictionary = new Dictionary<EntityType, Dictionary<EntityType, Dictionary<EdmProperty, string>>>();	
+	foreach (EntitySet set in entitySets)
+	{
+		XmlNodeList nodes = mappingNode.SelectNodes(string.Format(".//ef:EntitySetMapping[@Name=\"{0}\"]/ef:EntityTypeMapping/ef:MappingFragment", set.Name), nsmgr);
+		foreach(XmlNode node in nodes)
+		{
+			string typeName=node.ParentNode.Attributes["TypeName"].Value;
+			if(typeName.StartsWith("IsTypeOf("))
+				typeName=typeName.Substring("IsTypeOf(".Length, typeName.Length-"IsTypeOf()".Length);
+			EntityType type=entityTypes.Single(z=>z.FullName==typeName);
+			string tableName = node.Attributes["StoreEntitySet"].Value;
+			EntitySet set2 = tableSets.Single(entitySet => entitySet.Name == tableName);
+			var entityMap = new Dictionary<EdmProperty, string>();
+			
+			XmlNodeList propertyNodes = node.SelectNodes("./ef:Condition", nsmgr);
+			if(propertyNodes.Count==0) continue;
+			foreach(XmlNode propertyNode in propertyNodes)
+			{
+				string str = propertyNode.Attributes["ColumnName"].Value;
+				EdmProperty property2 = set2.ElementType.Properties[str];
+				string val=propertyNode.Attributes["Value"].Value;
+				entityMap.Add(property2, val);
+			}
+			EntityType baseType=(EntityType)(type.BaseType??type);
+			if(!dictionary.Keys.Contains(baseType))
+			{
+			var entityMappings=new Dictionary<EntityType, Dictionary<EdmProperty, string>>();
+			//entityMappings.Add(type,entityMap);
+			dictionary.Add(baseType, entityMappings);
+			}
+			dictionary[baseType].Add(type,entityMap);
+		}
+	}
+	return dictionary;
+}		
+
+private Dictionary<EntityType, Tuple<EntitySet, Dictionary<EdmProperty, EdmProperty>>> BuildEntityMappings(XmlNode mappingNode, XmlNamespaceManager nsmgr, IEnumerable<EntityType> entityTypes, IEnumerable<EntitySet> entitySets, IEnumerable<EntitySet> tableSets)
+{
+	var dictionary = new Dictionary<EntityType, Tuple<EntitySet, Dictionary<EdmProperty, EdmProperty>>>();
+
+	foreach (EntitySet set in entitySets)
+	{
+		XmlNodeList nodes = mappingNode.SelectNodes(string.Format(".//ef:EntitySetMapping[@Name=\"{0}\"]/ef:EntityTypeMapping/ef:MappingFragment", set.Name), nsmgr);
+		foreach(XmlNode node in nodes)
+		{
+			string typeName=node.ParentNode.Attributes["TypeName"].Value;
+			if(typeName.StartsWith("IsTypeOf("))
+				typeName=typeName.Substring("IsTypeOf(".Length, typeName.Length-"IsTypeOf()".Length);
+			EntityType type=entityTypes.Single(z=>z.FullName==typeName);
+			string tableName = node.Attributes["StoreEntitySet"].Value;
+			EntitySet set2 = tableSets.Single(entitySet => entitySet.Name == tableName);
+			var entityMap = new Dictionary<EdmProperty, EdmProperty>();
+			foreach (EdmProperty property in type.Properties)
+			{
+				XmlNode propertyNode = node.SelectSingleNode(string.Format("./ef:ScalarProperty[@Name=\"{0}\"]", property.Name), nsmgr);
+				if(propertyNode == null) continue;
+				string str = propertyNode.Attributes["ColumnName"].Value;
+				EdmProperty property2 = set2.ElementType.Properties[str];
+				entityMap.Add(property, property2);
+			}
+			dictionary.Add(type, Tuple.Create(set2, entityMap));
+		}
+	}
+	return dictionary;
+}
+
+Dictionary<AssociationType, Tuple<EntitySet, Dictionary<RelationshipEndMember, Dictionary<EdmMember, string>>>> BuildManyToManyMappings(XmlNode mappingNode, XmlNamespaceManager nsmgr, IEnumerable<AssociationSet> associationSets, IEnumerable<EntitySet> tableSets)
+{
+	var dictionary = new Dictionary<AssociationType, Tuple<EntitySet, Dictionary<RelationshipEndMember, Dictionary<EdmMember, string>>>>();
+	foreach (AssociationSet associationSet in associationSets.Where(set => set.ElementType.IsManyToMany()))
+	{
+		
+		XmlNode node = mappingNode.SelectSingleNode(string.Format("//ef:AssociationSetMapping[@Name=\"{0}\"]", associationSet.Name), nsmgr);
+		string tableName = node.Attributes["StoreEntitySet"].Value;
+		EntitySet entitySet = tableSets.Single(s => s.Name == tableName);
+		
+		var relationEndMap = new Dictionary<RelationshipEndMember, Dictionary<EdmMember, string>>();
+		foreach (AssociationSetEnd end in associationSet.AssociationSetEnds)
+		{
+			var map = new Dictionary<EdmMember, string>();
+			foreach (XmlNode endProperty in node.SelectSingleNode(string.Format("./ef:EndProperty[@Name=\"{0}\"]", end.Name), nsmgr).ChildNodes)
+			{
+				string str = endProperty.Attributes["Name"].Value;
+				EdmProperty key = end.EntitySet.ElementType.Properties[str];
+				string str2 = endProperty.Attributes["ColumnName"].Value;
+				map.Add(key, str2);
+			}
+			relationEndMap.Add(end.CorrespondingAssociationEndMember, map);
+		}
+		dictionary.Add(associationSet.ElementType, Tuple.Create(entitySet, relationEndMap));
+	}
+	return dictionary;
+}
+
+public class MetadataLoadResult
+{
+	public EdmItemCollection EdmItems { get; set; }
+	public Dictionary<EntityType, Tuple<EntitySet, Dictionary<EdmProperty, EdmProperty>>> PropertyToColumnMapping { get; set; }
+	public Dictionary<AssociationType, Tuple<EntitySet, Dictionary<RelationshipEndMember, Dictionary<EdmMember, string>>>> ManyToManyMappings { get; set; }
+	public Dictionary<EntityType, Dictionary<EntityType, Dictionary<EdmProperty, string>>> TphMappings { get; set; }
+}
+
+/// <summary>
+/// Responsible for encapsulating the constants defined in Metadata
+/// </summary>
+public static class MetadataConsts
+{
+    public const string CSDL_EXTENSION = ".csdl";
+
+    public const string CSDL_EDMX_SECTION_NAME = "ConceptualModels";
+    public const string CSDL_ROOT_ELEMENT_NAME = "Schema";
+    public const string EDM_ANNOTATION_09_02 = "http://schemas.microsoft.com/ado/2009/02/edm/annotation";
+
+    public const string SSDL_EXTENSION = ".ssdl";
+
+    public const string SSDL_EDMX_SECTION_NAME = "StorageModels";
+    public const string SSDL_ROOT_ELEMENT_NAME = "Schema";
+
+    public const string MSL_EXTENSION = ".msl";
+
+    public const string MSL_EDMX_SECTION_NAME = "Mappings";
+    public const string MSL_ROOT_ELEMENT_NAME = "Mapping";
+
+    public const string TT_TEMPLATE_NAME = "TemplateName";
+    public const string TT_TEMPLATE_VERSION = "TemplateVersion";
+    public const string TT_MINIMUM_ENTITY_FRAMEWORK_VERSION = "MinimumEntityFrameworkVersion";
+
+    public const string DEFAULT_TEMPLATE_VERSION = "4.0";
+
+    public static readonly SchemaConsts V1_SCHEMA_CONSTANTS = new SchemaConsts(
+        "http://schemas.microsoft.com/ado/2007/06/edmx",
+        "http://schemas.microsoft.com/ado/2006/04/edm",
+        "http://schemas.microsoft.com/ado/2006/04/edm/ssdl",
+        "urn:schemas-microsoft-com:windows:storage:mapping:CS",
+        new Version("3.5"));
+
+    public static readonly SchemaConsts V2_SCHEMA_CONSTANTS = new SchemaConsts(
+        "http://schemas.microsoft.com/ado/2008/10/edmx",
+        "http://schemas.microsoft.com/ado/2008/09/edm",
+        "http://schemas.microsoft.com/ado/2009/02/edm/ssdl",
+        "http://schemas.microsoft.com/ado/2008/09/mapping/cs",
+        new Version("4.0"));
+
+    public static readonly SchemaConsts V3_SCHEMA_CONSTANTS = new SchemaConsts(
+        "http://schemas.microsoft.com/ado/2009/11/edmx",
+        "http://schemas.microsoft.com/ado/2009/11/edm",
+        "http://schemas.microsoft.com/ado/2009/11/edm/ssdl",
+        "http://schemas.microsoft.com/ado/2009/11/mapping/cs",
+        new Version("4.5"));
+}
+
+public struct SchemaConsts
+{
+    public SchemaConsts(string edmxNamespace, string csdlNamespace, string ssdlNamespace, string mslNamespace, Version minimumTemplateVersion) : this()
+    {
+        EdmxNamespace = edmxNamespace;
+        CsdlNamespace = csdlNamespace;
+        SsdlNamespace = ssdlNamespace;
+        MslNamespace = mslNamespace;
+        MinimumTemplateVersion = minimumTemplateVersion;
+    }
+
+   public string EdmxNamespace { get; private set; }
+    public string CsdlNamespace { get; private set; }
+    public string SsdlNamespace { get; private set; }
+    public string MslNamespace { get; private set; }
+    public Version MinimumTemplateVersion { get; private set; }
+}
+#>

+ 9 - 0
EMIS.Entities.Log/EMIS.Entities.Log.cs

@@ -0,0 +1,9 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated from a template.
+//
+//    Manual changes to this file may cause unexpected behavior in your application.
+//    Manual changes to this file will be overwritten if the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+

+ 143 - 0
EMIS.Entities.Log/EMIS.Entities.Log.csproj

@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{DB95178F-587B-4F96-88DA-D4FD8EF75BFF}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>EMIS.Entities.Log</RootNamespace>
+    <AssemblyName>EMIS.Entities.Log</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SccProjectName>Svn</SccProjectName>
+    <SccLocalPath>Svn</SccLocalPath>
+    <SccAuxPath>Svn</SccAuxPath>
+    <SccProvider>SubversionScc</SccProvider>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+      <HintPath>..\packages\EntityFramework.6.1.3\lib\net40\EntityFramework.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="EntityFramework.Extended, Version=6.0.0.0, Culture=neutral, PublicKeyToken=05b7e29bdd433584, processorArchitecture=MSIL">
+      <HintPath>..\packages\EntityFramework.Extended.6.1.0.168\lib\net40\EntityFramework.Extended.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+      <HintPath>..\packages\EntityFramework.6.1.3\lib\net40\EntityFramework.SqlServer.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="Spire.Barcode, Version=2.3.0.16040, Culture=neutral, PublicKeyToken=663f351905198cb3, processorArchitecture=MSIL">
+      <HintPath>..\packages\FreeSpire.Barcode.2.3\lib\net40\Spire.Barcode.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.ComponentModel.DataAnnotations" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Data.Entity" />
+    <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="System.Security" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="EMIS.Entities.Log.Context.cs">
+      <DependentUpon>EMIS.Entities.Log.Context.tt</DependentUpon>
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+    </Compile>
+    <Compile Include="EMIS.Entities.Log.cs">
+      <DependentUpon>EMIS.Entities.Log.tt</DependentUpon>
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+    </Compile>
+    <Compile Include="EMIS.Entities.Log.Mapping.cs">
+      <DependentUpon>EMIS.Entities.Log.Mapping.tt</DependentUpon>
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+    </Compile>
+    <Compile Include="EMISLogContext.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>EMISLogContext.edmx</DependentUpon>
+    </Compile>
+    <Compile Include="Log_Operate.cs">
+      <DependentUpon>EMIS.Entities.Log.tt</DependentUpon>
+    </Compile>
+    <Compile Include="Log_Operate_Mapping.cs">
+      <DependentUpon>EMIS.Entities.Log.Mapping.tt</DependentUpon>
+    </Compile>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="TableKey.cs">
+      <DependentUpon>TableKey.tt</DependentUpon>
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+    </Compile>
+    <Compile Include="VW_Sys_User.cs">
+      <DependentUpon>EMIS.Entities.Log.tt</DependentUpon>
+    </Compile>
+    <Compile Include="VW_Sys_User_Mapping.cs">
+      <DependentUpon>EMIS.Entities.Log.Mapping.tt</DependentUpon>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+    <None Include="EMISLogContext.edmx">
+      <Generator>EntityModelCodeGenerator</Generator>
+      <LastGenOutput>EMISLogContext.Designer.cs</LastGenOutput>
+    </None>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="EMIS.Entities.Log.Context.tt">
+      <Generator>TextTemplatingFileGenerator</Generator>
+      <LastGenOutput>EMIS.Entities.Log.Context.cs</LastGenOutput>
+    </Content>
+    <Content Include="EMIS.Entities.Log.tt">
+      <Generator>TextTemplatingFileGenerator</Generator>
+      <LastGenOutput>EMIS.Entities.Log.cs</LastGenOutput>
+    </Content>
+    <Content Include="EMIS.Entities.Log.Mapping.tt">
+      <Generator>TextTemplatingFileGenerator</Generator>
+      <LastGenOutput>EMIS.Entities.Log.Mapping.cs</LastGenOutput>
+    </Content>
+    <Content Include="TableKey.tt">
+      <Generator>TextTemplatingFileGenerator</Generator>
+      <LastGenOutput>TableKey.cs</LastGenOutput>
+    </Content>
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 311 - 0
EMIS.Entities.Log/EMIS.Entities.Log.tt

@@ -0,0 +1,311 @@
+<#@ template language="C#" debug="false" hostspecific="true"#>
+<#@ include file="EF.Utility.CS.ttinclude"#><#@
+ output extension=".cs"#><#
+
+CodeGenerationTools code = new CodeGenerationTools(this);
+MetadataLoader loader = new MetadataLoader(this);
+CodeRegion region = new CodeRegion(this, 1);
+MetadataTools ef = new MetadataTools(this);
+
+string inputFile = @"EMISLogContext.edmx";
+EdmItemCollection ItemCollection = loader.CreateEdmItemCollection(inputFile);
+string namespaceName = code.VsNamespaceSuggestion();
+
+EntityFrameworkTemplateFileManager fileManager = EntityFrameworkTemplateFileManager.Create(this);
+WriteHeader(fileManager);
+
+string summary=string.Empty;
+
+foreach (EntityType entity in ItemCollection.GetItems<EntityType>().OrderBy(e => e.Name))
+{
+    fileManager.StartNewFile(entity.Name + ".cs");
+    BeginNamespace(namespaceName, code);
+	if(entity.Documentation !=null && entity.Documentation.Summary!=null)
+       summary=entity.Documentation.Summary;
+    else
+       summary=entity.Name;	
+#>
+#pragma warning disable 1573
+using System;
+using System.Collections.Generic;
+
+/// <summary>
+/// <#=summary#>
+/// </summary>
+<#=Accessibility.ForType(entity)#> <#=code.SpaceAfter(code.AbstractOption(entity))#>partial class <#=code.Escape(entity)#><#=code.StringBefore(" : ", code.Escape(entity.BaseType))#>
+{
+<#
+    
+	var propertiesWithDefaultValues = entity.Properties.Where(p => p.TypeUsage.EdmType is PrimitiveType && p.DeclaringType == entity && p.DefaultValue != null);
+    var collectionNavigationProperties = entity.NavigationProperties.Where(np => np.DeclaringType == entity && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
+    var complexProperties = entity.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == entity);
+	
+    if (propertiesWithDefaultValues.Any() || collectionNavigationProperties.Any() || complexProperties.Any())
+    {
+#>
+    public <#=code.Escape(entity)#>()
+    {
+<#
+        foreach (var edmProperty in propertiesWithDefaultValues)
+        {
+#>
+        this.<#=code.Escape(edmProperty)#> = <#=code.CreateLiteral(edmProperty.DefaultValue)#>;
+<#
+        }
+
+        foreach (var navigationProperty in collectionNavigationProperties)
+        {
+#>
+        this.<#=code.Escape(navigationProperty)#> = new HashSet<<#=code.Escape(navigationProperty.ToEndMember.GetEntityType())#>>();
+<#
+        }
+
+        foreach (var complexProperty in complexProperties)
+        {
+#>
+        this.<#=code.Escape(complexProperty)#> = new <#=code.Escape(complexProperty.TypeUsage)#>();
+<#
+        }
+#>
+    }
+
+<#
+    }
+
+    var primitiveProperties = entity.Properties.Where(p => p.TypeUsage.EdmType is PrimitiveType && p.DeclaringType == entity);
+    if (primitiveProperties.Any())
+    {
+        foreach (var edmProperty in primitiveProperties)
+        {
+            WriteProperty(code, edmProperty);
+        }
+    }
+
+    if (complexProperties.Any())
+    {
+#>
+
+<#
+        foreach(var complexProperty in complexProperties)
+        {
+            WriteProperty(code, complexProperty);
+        }
+    }
+
+    var navigationProperties = entity.NavigationProperties.Where(np => np.DeclaringType == entity);
+    if (navigationProperties.Any())
+    {
+#>
+
+<#
+        foreach (var navigationProperty in navigationProperties)
+        {
+            WriteNavigationProperty(code, navigationProperty);
+        }
+    }
+#>
+}
+<#
+    EndNamespace(namespaceName);
+}
+
+foreach (var complex in ItemCollection.GetItems<ComplexType>().OrderBy(e => e.Name))
+{
+    fileManager.StartNewFile(complex.Name + ".cs");
+    BeginNamespace(namespaceName, code);
+#>
+using System;
+
+<#=Accessibility.ForType(complex)#> partial class <#=code.Escape(complex)#>
+{
+<#
+    var complexProperties = complex.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == complex);
+    var propertiesWithDefaultValues = complex.Properties.Where(p => p.TypeUsage.EdmType is PrimitiveType && p.DeclaringType == complex && p.DefaultValue != null);
+
+    if (propertiesWithDefaultValues.Any() || complexProperties.Any())
+    {
+#>
+    public <#=code.Escape(complex)#>()
+    {
+<#
+        foreach (var edmProperty in propertiesWithDefaultValues)
+        {
+#>
+        this.<#=code.Escape(edmProperty)#> = <#=code.CreateLiteral(edmProperty.DefaultValue)#>;
+<#
+        }
+
+        foreach (var complexProperty in complexProperties)
+        {
+#>
+        this.<#=code.Escape(complexProperty)#> = new <#=code.Escape(complexProperty.TypeUsage)#>();
+<#
+        }
+#>
+    }
+
+<#
+    }
+
+    var primitiveProperties = complex.Properties.Where(p => p.TypeUsage.EdmType is PrimitiveType && p.DeclaringType == complex);
+    if (primitiveProperties.Any())
+    {
+        foreach(var edmProperty in primitiveProperties)
+        {
+            WriteProperty(code, edmProperty);
+        }
+    }
+
+    if (complexProperties.Any())
+    {
+#>
+
+<#
+        foreach(var edmProperty in complexProperties)
+        {
+            WriteProperty(code, edmProperty);
+        }
+    }
+#>
+}
+<#
+    EndNamespace(namespaceName);
+}
+
+if (!VerifyTypesAreCaseInsensitiveUnique(ItemCollection))
+{
+    return "";
+}
+
+fileManager.Process();
+
+#>
+<#+
+void WriteHeader(EntityFrameworkTemplateFileManager fileManager)
+{
+    fileManager.StartHeader();
+#>
+//------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated from a template.
+//
+//    Manual changes to this file may cause unexpected behavior in your application.
+//    Manual changes to this file will be overwritten if the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+<#+
+    fileManager.EndBlock();
+}
+
+void BeginNamespace(string namespaceName, CodeGenerationTools code)
+{
+    CodeRegion region = new CodeRegion(this);
+    if (!String.IsNullOrEmpty(namespaceName))
+    {
+#>
+namespace <#=code.EscapeNamespace(namespaceName)#>
+{
+<#+
+        PushIndent(CodeRegion.GetIndent(1));
+    }
+}
+
+
+void EndNamespace(string namespaceName)
+{
+    if (!String.IsNullOrEmpty(namespaceName))
+    {
+        PopIndent();
+#>
+}
+<#+
+    }
+}
+
+void WriteProperty(CodeGenerationTools code, EdmProperty edmProperty)
+{
+	if (edmProperty.Documentation != null && edmProperty.Documentation.Summary != null)
+    { 
+        WriteProperty(Accessibility.ForProperty(edmProperty),
+                      code.Escape(edmProperty.Documentation.Summary),
+                      code.Escape(edmProperty.TypeUsage),
+                      code.Escape(edmProperty),
+                      code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
+                      code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
+    }
+    else
+    {
+        WriteProperty(Accessibility.ForProperty(edmProperty),
+                      code.Escape(edmProperty.Name),
+                      code.Escape(edmProperty.TypeUsage),
+                      code.Escape(edmProperty),
+                      code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
+                      code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
+    }
+}
+
+void WriteNavigationProperty(CodeGenerationTools code, NavigationProperty navigationProperty)
+{
+    var endType = code.Escape(navigationProperty.ToEndMember.GetEntityType());
+
+	if (navigationProperty.Documentation != null && navigationProperty.Documentation.Summary != null)
+    { 
+		WriteProperty(PropertyVirtualModifier(Accessibility.ForProperty(navigationProperty)),
+					  code.Escape(navigationProperty.Documentation.Summary),
+					  navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("HashSet<" + endType + ">") : endType,
+					  code.Escape(navigationProperty),
+					  code.SpaceAfter(Accessibility.ForGetter(navigationProperty)),
+					  code.SpaceAfter(Accessibility.ForSetter(navigationProperty)));
+    }
+    else
+    {
+		WriteProperty(PropertyVirtualModifier(Accessibility.ForProperty(navigationProperty)),
+					code.Escape(navigationProperty.Name),
+					navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("HashSet<" + endType + ">") : endType,
+					code.Escape(navigationProperty),
+					code.SpaceAfter(Accessibility.ForGetter(navigationProperty)),
+					code.SpaceAfter(Accessibility.ForSetter(navigationProperty)));
+    }
+
+}
+
+void WriteProperty(string accessibility, string summary, string type, string name, string getterAccessibility, string setterAccessibility)
+{
+#>
+	/// <summary>
+    /// <#=summary#>
+    /// </summary>
+    <#=accessibility#> <#=type#> <#=name#> { <#=getterAccessibility#>get; <#=setterAccessibility#>set; }
+<#+
+}
+
+string PropertyVirtualModifier(string accessibility)
+{
+    return accessibility + (accessibility != "private" ? " virtual" : "");
+}
+
+bool VerifyTypesAreCaseInsensitiveUnique(EdmItemCollection itemCollection)
+{
+    var alreadySeen = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
+    foreach(var type in itemCollection.GetItems<StructuralType>())
+    {
+        if (!(type is EntityType || type is ComplexType))
+        {
+            continue;
+        }
+
+        if (alreadySeen.ContainsKey(type.FullName))
+        {
+            Error(String.Format(CultureInfo.CurrentCulture, "This template does not support types that differ only by case, the types {0} are not supported", type.FullName));
+            return false;
+        }
+        else
+        {
+            alreadySeen.Add(type.FullName, true);
+        }
+    }
+
+    return true;
+}
+#>

+ 4 - 0
EMIS.Entities.Log/EMISLogContext.Designer.cs

@@ -0,0 +1,4 @@
+// 模型“D:\开发项目\教务管理系统\源代码New\EMIS.Entities.Log\EMISLogContext.edmx”的默认代码生成功能已禁用。
+// 要启用默认代码生成功能,请将“代码生成策略”设计器属性的值
+// 更改为另一值。当在设计器中打开该模型时,此属性会出现在
+// “属性”窗口中。

+ 155 - 0
EMIS.Entities.Log/EMISLogContext.edmx

@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="utf-8"?>
+<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
+  <!-- EF Runtime content -->
+  <edmx:Runtime>
+    <!-- SSDL content -->
+    <edmx:StorageModels>
+      <Schema Namespace="EMIS.Entities.Log.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2008" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
+        <EntityContainer Name="EMISEntitiesLogStoreContainer">
+          <EntitySet Name="Log_Operate" EntityType="EMIS.Entities.Log.Store.Log_Operate" store:Type="Tables" Schema="dbo" />
+          <EntitySet Name="VW_Sys_User" EntityType="EMIS.Entities.Log.Store.VW_Sys_User" store:Type="Views" store:Schema="dbo" store:Name="VW_Sys_User">
+            <DefiningQuery>SELECT 
+      [VW_Sys_User].[UserID] AS [UserID], 
+      [VW_Sys_User].[LoginID] AS [LoginID], 
+      [VW_Sys_User].[Password] AS [Password], 
+      [VW_Sys_User].[Name] AS [Name], 
+      [VW_Sys_User].[RecordStatus] AS [RecordStatus], 
+      [VW_Sys_User].[CreateUserID] AS [CreateUserID], 
+      [VW_Sys_User].[CreateTime] AS [CreateTime], 
+      [VW_Sys_User].[ModifyUserID] AS [ModifyUserID], 
+      [VW_Sys_User].[ModifyTime] AS [ModifyTime]
+      FROM [dbo].[VW_Sys_User] AS [VW_Sys_User]</DefiningQuery>
+          </EntitySet>
+        </EntityContainer>
+        <EntityType Name="Log_Operate">
+          <Key>
+            <PropertyRef Name="OperateID" />
+          </Key>
+          <Property Name="OperateID" Type="uniqueidentifier" Nullable="false" />
+          <Property Name="UserID" Type="uniqueidentifier" />
+          <Property Name="IP" Type="varchar" MaxLength="50" />
+          <Property Name="TableName" Type="varchar" MaxLength="50" />
+          <Property Name="SourceUrl" Type="varchar" MaxLength="500" />
+          <Property Name="Operate" Type="nvarchar" MaxLength="50" />
+          <Property Name="Detail" Type="nvarchar(max)" />
+          <Property Name="IsSuccess" Type="bit" />
+          <Property Name="OperateTime" Type="datetime" />
+        </EntityType>
+        <!--生成过程中发现错误:
+      警告 6002: 表/视图“EMISNewLog.dbo.VW_Sys_User”未定义主键。已推断出该键,并将定义创建为只读的表/视图。
+      -->
+        <EntityType Name="VW_Sys_User">
+          <Key>
+            <PropertyRef Name="UserID" />
+          </Key>
+          <Property Name="UserID" Type="uniqueidentifier" Nullable="false" />
+          <Property Name="LoginID" Type="varchar" MaxLength="50" />
+          <Property Name="Password" Type="varchar" MaxLength="50" />
+          <Property Name="Name" Type="nvarchar" MaxLength="50" />
+          <Property Name="RecordStatus" Type="int" />
+          <Property Name="CreateUserID" Type="uniqueidentifier" />
+          <Property Name="CreateTime" Type="datetime" />
+          <Property Name="ModifyUserID" Type="uniqueidentifier" />
+          <Property Name="ModifyTime" Type="datetime" />
+        </EntityType>
+      </Schema>
+    </edmx:StorageModels>
+    <!-- CSDL content -->
+    <edmx:ConceptualModels>
+      <Schema Namespace="EMIS.Entities.Log" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
+        <EntityContainer Name="EMISNewLogContext" annotation:LazyLoadingEnabled="true">
+          <EntitySet Name="Log_Operate" EntityType="EMIS.Entities.Log.Log_Operate" />
+          <EntitySet Name="VW_Sys_User" EntityType="EMIS.Entities.Log.VW_Sys_User" />
+        </EntityContainer>
+        <EntityType Name="Log_Operate">
+          <Key>
+            <PropertyRef Name="OperateID" />
+          </Key>
+          <Property Name="OperateID" Type="Guid" Nullable="false" />
+          <Property Name="UserID" Type="Guid" />
+          <Property Name="IP" Type="String" MaxLength="50" Unicode="false" FixedLength="false" />
+          <Property Name="TableName" Type="String" MaxLength="50" Unicode="false" FixedLength="false" />
+          <Property Name="SourceUrl" Type="String" MaxLength="2000" Unicode="false" FixedLength="false" />
+          <Property Name="Operate" Type="String" MaxLength="50" Unicode="true" FixedLength="false" />
+          <Property Name="Detail" Type="String" MaxLength="Max" Unicode="true" FixedLength="false" />
+          <Property Name="IsSuccess" Type="Boolean" />
+          <Property Name="OperateTime" Type="DateTime" />
+        </EntityType>
+        <EntityType Name="VW_Sys_User">
+          <Key>
+            <PropertyRef Name="UserID" />
+          </Key>
+          <Property Name="UserID" Type="Guid" Nullable="false" />
+          <Property Name="LoginID" Type="String" MaxLength="50" Unicode="false" FixedLength="false" />
+          <Property Name="Password" Type="String" MaxLength="50" Unicode="false" FixedLength="false" />
+          <Property Name="Name" Type="String" MaxLength="50" Unicode="true" FixedLength="false" />
+          <Property Name="RecordStatus" Type="Int32" />
+          <Property Name="CreateUserID" Type="Guid" />
+          <Property Name="CreateTime" Type="DateTime" />
+          <Property Name="ModifyUserID" Type="Guid" />
+          <Property Name="ModifyTime" Type="DateTime" />
+        </EntityType>
+      </Schema>
+    </edmx:ConceptualModels>
+    <!-- C-S mapping content -->
+    <edmx:Mappings>
+      <Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs">
+        <EntityContainerMapping StorageEntityContainer="EMISEntitiesLogStoreContainer" CdmEntityContainer="EMISNewLogContext">
+          <EntitySetMapping Name="Log_Operate">
+            <EntityTypeMapping TypeName="EMIS.Entities.Log.Log_Operate">
+              <MappingFragment StoreEntitySet="Log_Operate">
+                <ScalarProperty Name="OperateID" ColumnName="OperateID" />
+                <ScalarProperty Name="UserID" ColumnName="UserID" />
+                <ScalarProperty Name="IP" ColumnName="IP" />
+                <ScalarProperty Name="TableName" ColumnName="TableName" />
+                <ScalarProperty Name="SourceUrl" ColumnName="SourceUrl" />
+                <ScalarProperty Name="Operate" ColumnName="Operate" />
+                <ScalarProperty Name="Detail" ColumnName="Detail" />
+                <ScalarProperty Name="IsSuccess" ColumnName="IsSuccess" />
+                <ScalarProperty Name="OperateTime" ColumnName="OperateTime" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="VW_Sys_User">
+            <EntityTypeMapping TypeName="EMIS.Entities.Log.VW_Sys_User">
+              <MappingFragment StoreEntitySet="VW_Sys_User">
+                <ScalarProperty Name="UserID" ColumnName="UserID" />
+                <ScalarProperty Name="LoginID" ColumnName="LoginID" />
+                <ScalarProperty Name="Password" ColumnName="Password" />
+                <ScalarProperty Name="Name" ColumnName="Name" />
+                <ScalarProperty Name="RecordStatus" ColumnName="RecordStatus" />
+                <ScalarProperty Name="CreateUserID" ColumnName="CreateUserID" />
+                <ScalarProperty Name="CreateTime" ColumnName="CreateTime" />
+                <ScalarProperty Name="ModifyUserID" ColumnName="ModifyUserID" />
+                <ScalarProperty Name="ModifyTime" ColumnName="ModifyTime" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+        </EntityContainerMapping>
+      </Mapping>
+    </edmx:Mappings>
+  </edmx:Runtime>
+  <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
+  <Designer xmlns="http://schemas.microsoft.com/ado/2008/10/edmx">
+    <Connection>
+      <DesignerInfoPropertySet>
+        <DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
+      </DesignerInfoPropertySet>
+    </Connection>
+    <Options>
+      <DesignerInfoPropertySet>
+        <DesignerProperty Name="ValidateOnBuild" Value="true" />
+        <DesignerProperty Name="EnablePluralization" Value="False" />
+        <DesignerProperty Name="IncludeForeignKeysInModel" Value="True" />
+        <DesignerProperty Name="CodeGenerationStrategy" Value="无" />
+      </DesignerInfoPropertySet>
+    </Options>
+    <!-- Diagram content (shape and connector positions) -->
+    <Diagrams>
+      <Diagram Name="EMISLogContext">
+        <EntityTypeShape EntityType="EMIS.Entities.Log.Log_Operate" Width="1.5" PointX="0.75" PointY="0.75" Height="2.6594042968749996" IsExpanded="true" />
+        <EntityTypeShape EntityType="EMIS.Entities.Log.VW_Sys_User" Width="1.5" PointX="2.75" PointY="0.75" Height="2.6594042968749996" IsExpanded="true" />
+      </Diagram>
+    </Diagrams>
+  </Designer>
+</edmx:Edmx>

+ 58 - 0
EMIS.Entities.Log/Log_Operate.cs

@@ -0,0 +1,58 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated from a template.
+//
+//    Manual changes to this file may cause unexpected behavior in your application.
+//    Manual changes to this file will be overwritten if the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace EMIS.Entities.Log
+{
+    #pragma warning disable 1573
+    using System;
+    using System.Collections.Generic;
+    
+    /// <summary>
+    /// Log_Operate
+    /// </summary>
+    public partial class Log_Operate
+    {
+    	/// <summary>
+        /// OperateID
+        /// </summary>
+        public System.Guid OperateID { get; set; }
+    	/// <summary>
+        /// UserID
+        /// </summary>
+        public Nullable<System.Guid> UserID { get; set; }
+    	/// <summary>
+        /// IP
+        /// </summary>
+        public string IP { get; set; }
+    	/// <summary>
+        /// TableName
+        /// </summary>
+        public string TableName { get; set; }
+    	/// <summary>
+        /// SourceUrl
+        /// </summary>
+        public string SourceUrl { get; set; }
+    	/// <summary>
+        /// Operate
+        /// </summary>
+        public string Operate { get; set; }
+    	/// <summary>
+        /// Detail
+        /// </summary>
+        public string Detail { get; set; }
+    	/// <summary>
+        /// IsSuccess
+        /// </summary>
+        public Nullable<bool> IsSuccess { get; set; }
+    	/// <summary>
+        /// OperateTime
+        /// </summary>
+        public Nullable<System.DateTime> OperateTime { get; set; }
+    }
+}

+ 39 - 0
EMIS.Entities.Log/Log_Operate_Mapping.cs

@@ -0,0 +1,39 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated from a template.
+//
+//    Manual changes to this file may cause unexpected behavior in your application.
+//    Manual changes to this file will be overwritten if the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace EMIS.Entities.Log
+{
+    #pragma warning disable 1573
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel.DataAnnotations;
+    using System.Data.Common;
+    using System.Data.Entity;
+    using System.Data.Entity.ModelConfiguration;
+    using System.Data.Entity.Infrastructure;
+    using System.ComponentModel.DataAnnotations.Schema;
+    
+    internal partial class Log_Operate_Mapping : EntityTypeConfiguration<Log_Operate>
+    {
+        public Log_Operate_Mapping()
+        {					
+    		this.HasKey(t => t.OperateID);		
+    		this.ToTable("Log_Operate");
+    		this.Property(t => t.OperateID).HasColumnName("OperateID");
+    		this.Property(t => t.UserID).HasColumnName("UserID");
+    		this.Property(t => t.IP).HasColumnName("IP").IsUnicode(false).HasMaxLength(50);
+    		this.Property(t => t.TableName).HasColumnName("TableName").IsUnicode(false).HasMaxLength(50);
+    		this.Property(t => t.SourceUrl).HasColumnName("SourceUrl").IsUnicode(false).HasMaxLength(2000);
+    		this.Property(t => t.Operate).HasColumnName("Operate").HasMaxLength(50);
+    		this.Property(t => t.Detail).HasColumnName("Detail");
+    		this.Property(t => t.IsSuccess).HasColumnName("IsSuccess");
+    		this.Property(t => t.OperateTime).HasColumnName("OperateTime");
+    	}
+    }
+}

+ 36 - 0
EMIS.Entities.Log/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的常规信息通过以下
+// 特性集控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("EMIS.Entities.Log")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("EMIS.Entities.Log")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 使此程序集中的类型
+// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
+// 则将该类型上的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("936d862a-becc-456d-9ea3-d7272e1fec1f")]
+
+// 程序集的版本信息由下面四个值组成:
+//
+//      主版本
+//      次版本 
+//      内部版本号
+//      修订号
+//
+// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 44 - 0
EMIS.Entities.Log/TableKey.cs

@@ -0,0 +1,44 @@
+
+//------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated from a template.
+//
+//    Manual changes to this file may cause unexpected behavior in your application.
+//    Manual changes to this file will be overwritten if the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+
+using System.Collections.Generic;
+namespace EMIS.Entities.Log
+{
+	public class TableKeyDictionary
+	{
+        private static Dictionary<string, string> items;
+        public static Dictionary<string, string> Items
+        {
+            get { return items; }
+        }
+
+		static TableKeyDictionary()
+        {
+			items = new Dictionary<string, string>();
+			items.Add("Log_Operate", "OperateID");
+			items.Add("VW_Sys_User", "UserID");
+		}
+
+		public static string GetKeyName<TEntity>(TEntity entity)
+		{
+			string tableName = typeof(TEntity).Name;
+
+			return items[tableName];
+		}
+
+		public static string GetKeyName<TEntity>()
+		{
+			string tableName = typeof(TEntity).Name;
+
+			return items[tableName];
+		}
+	}
+}

+ 396 - 0
EMIS.Entities.Log/TableKey.tt

@@ -0,0 +1,396 @@
+<#@ template language="C#" debug="false" hostspecific="true"#>
+<#@ include file="EF.Utility.CS.ttinclude"#>
+<#@ assembly name="$(DevEnvDir)Microsoft.Data.Entity.Design.DatabaseGeneration.dll"#>
+<#@ import namespace="Microsoft.Data.Entity.Design.DatabaseGeneration" #>
+<#@ import namespace="System.Text"#>
+<#@ output extension=".cs"#><#
+CodeGenerationTools code = new CodeGenerationTools(this);
+CodeRegion region = new CodeRegion(this, 1);
+MetadataTools ef = new MetadataTools(this);
+string inputFile = @"EMISLogContext.edmx";
+
+var loadResult = LoadMetadata(inputFile);
+EdmItemCollection itemCollection = loadResult.EdmItems;
+var propertyToColumnMapping = loadResult.PropertyToColumnMapping;
+var manyToManyMappings = loadResult.ManyToManyMappings;
+var tphMappings = loadResult.TphMappings;
+string namespaceName = code.VsNamespaceSuggestion();
+string mapClassSuffix = "_Mapping";
+EntityFrameworkTemplateFileManager fileManager = EntityFrameworkTemplateFileManager.Create(this);
+WriteHeader(fileManager);#>
+
+using System.Collections.Generic;
+namespace EMIS.Entities.Log
+{
+	public class TableKeyDictionary
+	{
+        private static Dictionary<string, string> items;
+        public static Dictionary<string, string> Items
+        {
+            get { return items; }
+        }
+
+		static TableKeyDictionary()
+        {
+			items = new Dictionary<string, string>();
+<#foreach (EntityType entity in itemCollection.GetItems<EntityType>().OrderBy(e => e.Name))
+{
+	string hasKey;
+	hasKey = string.Format("items.Add(\"{0}\", \"{1}\");", entity.Name, entity.KeyMembers[0].Name);#>
+			<#=hasKey#>
+<#}
+#>
+		}
+
+		public static string GetKeyName<TEntity>(TEntity entity)
+		{
+			string tableName = typeof(TEntity).Name;
+
+			return items[tableName];
+		}
+
+		public static string GetKeyName<TEntity>()
+		{
+			string tableName = typeof(TEntity).Name;
+
+			return items[tableName];
+		}
+	}
+}
+<#+
+string GetResourceString(string resourceName)
+{
+	if(_resourceManager2 == null)
+	{
+		_resourceManager2 = new System.Resources.ResourceManager("System.Data.Entity.Design", typeof(System.Data.Entity.Design.MetadataItemCollectionFactory).Assembly);
+	}
+	
+    return _resourceManager2.GetString(resourceName, null);
+}
+System.Resources.ResourceManager _resourceManager2;
+
+void WriteHeader(EntityFrameworkTemplateFileManager fileManager)
+{
+    fileManager.StartHeader();
+#>
+//------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated from a template.
+//
+//    Manual changes to this file may cause unexpected behavior in your application.
+//    Manual changes to this file will be overwritten if the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+<#+
+    fileManager.EndBlock();
+}
+
+void BeginNamespace(string namespaceName, CodeGenerationTools code)
+{
+    CodeRegion region = new CodeRegion(this);
+    if (!String.IsNullOrEmpty(namespaceName))
+    {
+#>
+namespace <#=code.EscapeNamespace(namespaceName)#>
+{
+<#+
+        PushIndent(CodeRegion.GetIndent(1));
+    }
+}
+
+
+void EndNamespace(string namespaceName)
+{
+    if (!String.IsNullOrEmpty(namespaceName))
+    {
+        PopIndent();
+#>
+}
+<#+
+    }
+}
+string ToTable(EntitySet entitySet)
+{
+	var toTable = entitySet.Name;
+	string schema = entitySet.GetSchemaName();
+	if(!string.IsNullOrWhiteSpace(schema) && schema != "dbo")	
+		toTable += "\", \"" + schema;
+	return toTable;
+}
+
+bool VerifyTypesAreCaseInsensitiveUnique(EdmItemCollection itemCollection)
+{
+    var alreadySeen = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
+    foreach(var type in itemCollection.GetItems<StructuralType>())
+    {
+        if (!(type is EntityType || type is ComplexType))
+        {
+            continue;
+        }
+
+        if (alreadySeen.ContainsKey(type.FullName))
+        {
+            Error(String.Format(CultureInfo.CurrentCulture, "This template does not support types that differ only by case, the types {0} are not supported", type.FullName));
+            return false;
+        }
+        else
+        {
+            alreadySeen.Add(type.FullName, true);
+        }
+    }
+
+    return true;
+}
+
+string GetGenerationOption(EdmProperty property, EntityType entity)
+{
+	string result = "";
+	bool isPk = entity.KeyMembers.Contains(property);
+	MetadataProperty storeGeneratedPatternProperty = null;
+	string storeGeneratedPatternPropertyValue = "None";
+	
+	if(property.MetadataProperties.TryGetValue(MetadataConsts.EDM_ANNOTATION_09_02 + ":StoreGeneratedPattern", false, out storeGeneratedPatternProperty))	
+		storeGeneratedPatternPropertyValue = storeGeneratedPatternProperty.Value.ToString();		
+	
+	PrimitiveType edmType = (PrimitiveType) property.TypeUsage.EdmType; 
+	if (storeGeneratedPatternPropertyValue == "Computed")
+	{
+	    result = ".HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed)";
+	}
+	else if ((edmType.ClrEquivalentType == typeof(int)) || (edmType.ClrEquivalentType == typeof(short)) || (edmType.ClrEquivalentType == typeof(long)))
+	{
+	    if (isPk && (storeGeneratedPatternPropertyValue != "Identity"))
+	        result = ".HasDatabaseGeneratedOption(DatabaseGeneratedOption.None)";
+	    else if ((!isPk || (entity.KeyMembers.Count > 1)) && (storeGeneratedPatternPropertyValue == "Identity"))
+	        result = ".HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)";
+	}	
+	return result;    
+}
+
+MetadataLoadResult LoadMetadata(string inputFile)
+{       
+	var loader = new MetadataLoader(this);
+	bool loaded = false;
+	EdmItemCollection edmItemCollection = loader.CreateEdmItemCollection(inputFile);      
+	StoreItemCollection storeItemCollection = null;
+	if (loader.TryCreateStoreItemCollection(inputFile, out storeItemCollection))
+	{
+		StorageMappingItemCollection storageMappingItemCollection;
+		if (loader.TryCreateStorageMappingItemCollection(inputFile, edmItemCollection, storeItemCollection, out storageMappingItemCollection))
+			loaded = true;
+	}
+
+	if(loaded == false)
+		throw new Exception("Cannot load a metadata from the file " + inputFile);
+
+	var mappingMetadata = LoadMappingMetadata(inputFile);
+	var mappingNode		= mappingMetadata.Item1;
+	var nsmgr			= mappingMetadata.Item2;
+
+	var allEntitySets = storeItemCollection.GetAllEntitySets();		
+
+	return new MetadataLoadResult
+	       	{
+	       		EdmItems = edmItemCollection,
+	       		PropertyToColumnMapping = BuildEntityMappings(mappingNode, nsmgr, edmItemCollection.GetItems<EntityType>(), edmItemCollection.GetAllEntitySets(), allEntitySets),
+	       		ManyToManyMappings = BuildManyToManyMappings(mappingNode, nsmgr, edmItemCollection.GetAllAssociationSets(), allEntitySets),
+				TphMappings=BuildTPHMappings(mappingNode, nsmgr, edmItemCollection.GetItems<EntityType>(), edmItemCollection.GetAllEntitySets(), allEntitySets)
+	       	};
+}
+
+private Tuple<XmlNode, XmlNamespaceManager> LoadMappingMetadata(string inputFile)
+{
+	var xmlDoc = new XmlDocument();
+     xmlDoc.Load(Host.ResolvePath(inputFile));
+
+	 var schemaConstantsList = new SchemaConsts[]
+					{						
+						MetadataConsts.V2_SCHEMA_CONSTANTS,
+						MetadataConsts.V1_SCHEMA_CONSTANTS
+					};
+	foreach (var schemaConstants in schemaConstantsList)
+	{
+		var nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
+		nsmgr.AddNamespace("ef", schemaConstants.MslNamespace);
+		nsmgr.AddNamespace("edmx", schemaConstants.EdmxNamespace);
+		var mappingNode = xmlDoc.DocumentElement.SelectSingleNode("./*/edmx:Mappings", nsmgr);
+
+		if(mappingNode != null)
+			return Tuple.Create(mappingNode, nsmgr);
+	}     
+
+	throw new Exception(GetResourceString("Template_UnsupportedSchema"));
+}
+
+private Dictionary<EntityType, Dictionary<EntityType, Dictionary<EdmProperty, string>>> BuildTPHMappings(XmlNode mappingNode, XmlNamespaceManager nsmgr, IEnumerable<EntityType> entityTypes, IEnumerable<EntitySet> entitySets, IEnumerable<EntitySet> tableSets)
+{
+	var dictionary = new Dictionary<EntityType, Dictionary<EntityType, Dictionary<EdmProperty, string>>>();	
+	foreach (EntitySet set in entitySets)
+	{
+		XmlNodeList nodes = mappingNode.SelectNodes(string.Format(".//ef:EntitySetMapping[@Name=\"{0}\"]/ef:EntityTypeMapping/ef:MappingFragment", set.Name), nsmgr);
+		foreach(XmlNode node in nodes)
+		{
+			string typeName=node.ParentNode.Attributes["TypeName"].Value;
+			if(typeName.StartsWith("IsTypeOf("))
+				typeName=typeName.Substring("IsTypeOf(".Length, typeName.Length-"IsTypeOf()".Length);
+			EntityType type=entityTypes.Single(z=>z.FullName==typeName);
+			string tableName = node.Attributes["StoreEntitySet"].Value;
+			EntitySet set2 = tableSets.Single(entitySet => entitySet.Name == tableName);
+			var entityMap = new Dictionary<EdmProperty, string>();
+			
+			XmlNodeList propertyNodes = node.SelectNodes("./ef:Condition", nsmgr);
+			if(propertyNodes.Count==0) continue;
+			foreach(XmlNode propertyNode in propertyNodes)
+			{
+				string str = propertyNode.Attributes["ColumnName"].Value;
+				EdmProperty property2 = set2.ElementType.Properties[str];
+				string val=propertyNode.Attributes["Value"].Value;
+				entityMap.Add(property2, val);
+			}
+			EntityType baseType=(EntityType)(type.BaseType??type);
+			if(!dictionary.Keys.Contains(baseType))
+			{
+			var entityMappings=new Dictionary<EntityType, Dictionary<EdmProperty, string>>();
+			//entityMappings.Add(type,entityMap);
+			dictionary.Add(baseType, entityMappings);
+			}
+			dictionary[baseType].Add(type,entityMap);
+		}
+	}
+	return dictionary;
+}		
+
+private Dictionary<EntityType, Tuple<EntitySet, Dictionary<EdmProperty, EdmProperty>>> BuildEntityMappings(XmlNode mappingNode, XmlNamespaceManager nsmgr, IEnumerable<EntityType> entityTypes, IEnumerable<EntitySet> entitySets, IEnumerable<EntitySet> tableSets)
+{
+	var dictionary = new Dictionary<EntityType, Tuple<EntitySet, Dictionary<EdmProperty, EdmProperty>>>();
+
+	foreach (EntitySet set in entitySets)
+	{
+		XmlNodeList nodes = mappingNode.SelectNodes(string.Format(".//ef:EntitySetMapping[@Name=\"{0}\"]/ef:EntityTypeMapping/ef:MappingFragment", set.Name), nsmgr);
+		foreach(XmlNode node in nodes)
+		{
+			string typeName=node.ParentNode.Attributes["TypeName"].Value;
+			if(typeName.StartsWith("IsTypeOf("))
+				typeName=typeName.Substring("IsTypeOf(".Length, typeName.Length-"IsTypeOf()".Length);
+			EntityType type=entityTypes.Single(z=>z.FullName==typeName);
+			string tableName = node.Attributes["StoreEntitySet"].Value;
+			EntitySet set2 = tableSets.Single(entitySet => entitySet.Name == tableName);
+			var entityMap = new Dictionary<EdmProperty, EdmProperty>();
+			foreach (EdmProperty property in type.Properties)
+			{
+				XmlNode propertyNode = node.SelectSingleNode(string.Format("./ef:ScalarProperty[@Name=\"{0}\"]", property.Name), nsmgr);
+				if(propertyNode == null) continue;
+				string str = propertyNode.Attributes["ColumnName"].Value;
+				EdmProperty property2 = set2.ElementType.Properties[str];
+				entityMap.Add(property, property2);
+			}
+			dictionary.Add(type, Tuple.Create(set2, entityMap));
+		}
+	}
+	return dictionary;
+}
+
+Dictionary<AssociationType, Tuple<EntitySet, Dictionary<RelationshipEndMember, Dictionary<EdmMember, string>>>> BuildManyToManyMappings(XmlNode mappingNode, XmlNamespaceManager nsmgr, IEnumerable<AssociationSet> associationSets, IEnumerable<EntitySet> tableSets)
+{
+	var dictionary = new Dictionary<AssociationType, Tuple<EntitySet, Dictionary<RelationshipEndMember, Dictionary<EdmMember, string>>>>();
+	foreach (AssociationSet associationSet in associationSets.Where(set => set.ElementType.IsManyToMany()))
+	{
+		
+		XmlNode node = mappingNode.SelectSingleNode(string.Format("//ef:AssociationSetMapping[@Name=\"{0}\"]", associationSet.Name), nsmgr);
+		string tableName = node.Attributes["StoreEntitySet"].Value;
+		EntitySet entitySet = tableSets.Single(s => s.Name == tableName);
+		
+		var relationEndMap = new Dictionary<RelationshipEndMember, Dictionary<EdmMember, string>>();
+		foreach (AssociationSetEnd end in associationSet.AssociationSetEnds)
+		{
+			var map = new Dictionary<EdmMember, string>();
+			foreach (XmlNode endProperty in node.SelectSingleNode(string.Format("./ef:EndProperty[@Name=\"{0}\"]", end.Name), nsmgr).ChildNodes)
+			{
+				string str = endProperty.Attributes["Name"].Value;
+				EdmProperty key = end.EntitySet.ElementType.Properties[str];
+				string str2 = endProperty.Attributes["ColumnName"].Value;
+				map.Add(key, str2);
+			}
+			relationEndMap.Add(end.CorrespondingAssociationEndMember, map);
+		}
+		dictionary.Add(associationSet.ElementType, Tuple.Create(entitySet, relationEndMap));
+	}
+	return dictionary;
+}
+
+public class MetadataLoadResult
+{
+	public EdmItemCollection EdmItems { get; set; }
+	public Dictionary<EntityType, Tuple<EntitySet, Dictionary<EdmProperty, EdmProperty>>> PropertyToColumnMapping { get; set; }
+	public Dictionary<AssociationType, Tuple<EntitySet, Dictionary<RelationshipEndMember, Dictionary<EdmMember, string>>>> ManyToManyMappings { get; set; }
+	public Dictionary<EntityType, Dictionary<EntityType, Dictionary<EdmProperty, string>>> TphMappings { get; set; }
+}
+
+/// <summary>
+/// Responsible for encapsulating the constants defined in Metadata
+/// </summary>
+public static class MetadataConsts
+{
+    public const string CSDL_EXTENSION = ".csdl";
+
+    public const string CSDL_EDMX_SECTION_NAME = "ConceptualModels";
+    public const string CSDL_ROOT_ELEMENT_NAME = "Schema";
+    public const string EDM_ANNOTATION_09_02 = "http://schemas.microsoft.com/ado/2009/02/edm/annotation";
+
+    public const string SSDL_EXTENSION = ".ssdl";
+
+    public const string SSDL_EDMX_SECTION_NAME = "StorageModels";
+    public const string SSDL_ROOT_ELEMENT_NAME = "Schema";
+
+    public const string MSL_EXTENSION = ".msl";
+
+    public const string MSL_EDMX_SECTION_NAME = "Mappings";
+    public const string MSL_ROOT_ELEMENT_NAME = "Mapping";
+
+    public const string TT_TEMPLATE_NAME = "TemplateName";
+    public const string TT_TEMPLATE_VERSION = "TemplateVersion";
+    public const string TT_MINIMUM_ENTITY_FRAMEWORK_VERSION = "MinimumEntityFrameworkVersion";
+
+    public const string DEFAULT_TEMPLATE_VERSION = "4.0";
+
+    public static readonly SchemaConsts V1_SCHEMA_CONSTANTS = new SchemaConsts(
+        "http://schemas.microsoft.com/ado/2007/06/edmx",
+        "http://schemas.microsoft.com/ado/2006/04/edm",
+        "http://schemas.microsoft.com/ado/2006/04/edm/ssdl",
+        "urn:schemas-microsoft-com:windows:storage:mapping:CS",
+        new Version("3.5"));
+
+    public static readonly SchemaConsts V2_SCHEMA_CONSTANTS = new SchemaConsts(
+        "http://schemas.microsoft.com/ado/2008/10/edmx",
+        "http://schemas.microsoft.com/ado/2008/09/edm",
+        "http://schemas.microsoft.com/ado/2009/02/edm/ssdl",
+        "http://schemas.microsoft.com/ado/2008/09/mapping/cs",
+        new Version("4.0"));
+
+    public static readonly SchemaConsts V3_SCHEMA_CONSTANTS = new SchemaConsts(
+        "http://schemas.microsoft.com/ado/2009/11/edmx",
+        "http://schemas.microsoft.com/ado/2009/11/edm",
+        "http://schemas.microsoft.com/ado/2009/11/edm/ssdl",
+        "http://schemas.microsoft.com/ado/2009/11/mapping/cs",
+        new Version("4.5"));
+}
+
+public struct SchemaConsts
+{
+    public SchemaConsts(string edmxNamespace, string csdlNamespace, string ssdlNamespace, string mslNamespace, Version minimumTemplateVersion) : this()
+    {
+        EdmxNamespace = edmxNamespace;
+        CsdlNamespace = csdlNamespace;
+        SsdlNamespace = ssdlNamespace;
+        MslNamespace = mslNamespace;
+        MinimumTemplateVersion = minimumTemplateVersion;
+    }
+
+   public string EdmxNamespace { get; private set; }
+    public string CsdlNamespace { get; private set; }
+    public string SsdlNamespace { get; private set; }
+    public string MslNamespace { get; private set; }
+    public Version MinimumTemplateVersion { get; private set; }
+}
+#>

+ 58 - 0
EMIS.Entities.Log/VW_Sys_User.cs

@@ -0,0 +1,58 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated from a template.
+//
+//    Manual changes to this file may cause unexpected behavior in your application.
+//    Manual changes to this file will be overwritten if the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace EMIS.Entities.Log
+{
+    #pragma warning disable 1573
+    using System;
+    using System.Collections.Generic;
+    
+    /// <summary>
+    /// VW_Sys_User
+    /// </summary>
+    public partial class VW_Sys_User
+    {
+    	/// <summary>
+        /// UserID
+        /// </summary>
+        public System.Guid UserID { get; set; }
+    	/// <summary>
+        /// LoginID
+        /// </summary>
+        public string LoginID { get; set; }
+    	/// <summary>
+        /// Password
+        /// </summary>
+        public string Password { get; set; }
+    	/// <summary>
+        /// Name
+        /// </summary>
+        public string Name { get; set; }
+    	/// <summary>
+        /// RecordStatus
+        /// </summary>
+        public Nullable<int> RecordStatus { get; set; }
+    	/// <summary>
+        /// CreateUserID
+        /// </summary>
+        public Nullable<System.Guid> CreateUserID { get; set; }
+    	/// <summary>
+        /// CreateTime
+        /// </summary>
+        public Nullable<System.DateTime> CreateTime { get; set; }
+    	/// <summary>
+        /// ModifyUserID
+        /// </summary>
+        public Nullable<System.Guid> ModifyUserID { get; set; }
+    	/// <summary>
+        /// ModifyTime
+        /// </summary>
+        public Nullable<System.DateTime> ModifyTime { get; set; }
+    }
+}

+ 40 - 0
EMIS.Entities.Log/VW_Sys_User_Mapping.cs

@@ -0,0 +1,40 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated from a template.
+//
+//    Manual changes to this file may cause unexpected behavior in your application.
+//    Manual changes to this file will be overwritten if the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace EMIS.Entities.Log
+{
+    #pragma warning disable 1573
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel.DataAnnotations;
+    using System.Data.Common;
+    using System.Data.Entity;
+    using System.Data.Entity.ModelConfiguration;
+    using System.Data.Entity.Infrastructure;
+    using System.ComponentModel.DataAnnotations.Schema;
+    
+    internal partial class VW_Sys_User_Mapping : EntityTypeConfiguration<VW_Sys_User>
+    {
+        public VW_Sys_User_Mapping()
+        {					
+    		this.HasKey(t => t.UserID);		
+    		this.ToTable("VW_Sys_User");
+    		this.Property(t => t.UserID).HasColumnName("UserID");
+    		this.Property(t => t.LoginID).HasColumnName("LoginID").IsUnicode(false).HasMaxLength(50);
+    		this.Property(t => t.Password).HasColumnName("Password").IsUnicode(false).HasMaxLength(50);
+    		this.Property(t => t.Name).HasColumnName("Name").HasMaxLength(50);
+    		this.Property(t => t.RecordStatus).HasColumnName("RecordStatus");
+    		this.Property(t => t.CreateUserID).HasColumnName("CreateUserID");
+    		this.Property(t => t.CreateTime).HasColumnName("CreateTime");
+    		this.Property(t => t.ModifyUserID).HasColumnName("ModifyUserID");
+    		this.Property(t => t.ModifyTime).HasColumnName("ModifyTime");
+    	}
+    }
+}
+

+ 6 - 0
EMIS.Entities.Log/packages.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="EntityFramework" version="6.1.3" targetFramework="net40" />
+  <package id="EntityFramework.Extended" version="6.1.0.168" targetFramework="net40" />
+  <package id="FreeSpire.Barcode" version="2.3" targetFramework="net40" />
+</packages>