public static List <TemplateName> GetModelNames() { //不适用代码生成器的类,例如无主键id的类 List <string> excludList = new List <string> { "Database", "ChangeTracker", "Configuration", "SysAccountRoles", "SysRoleMenus", "SysRoleFunctions" }; List <TemplateName> ModelNames = new List <TemplateName>(); Type t = new WebDbContext().GetType(); PropertyInfo[] PropertyList = t.GetProperties(); foreach (PropertyInfo item in PropertyList) { if (!excludList.Contains(item.Name)) { ModelNames.Add(new TemplateName { ModelName = ToSingular(item.Name), EntityName = item.Name }); } } return(ModelNames); }