CARVIEW |
Select Language
HTTP/2 200
date: Wed, 30 Jul 2025 00:13:58 GMT
content-type: text/html; charset=utf-8
cache-control: max-age=0, private, must-revalidate
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
link: ; rel=preload; as=fetch; crossorigin=use-credentials
referrer-policy: no-referrer-when-downgrade
server-timing: issue_layout-fragment;desc="issue_layout fragment";dur=302.355931,issue_conversation_content-fragment;desc="issue_conversation_content fragment";dur=596.72516,issue_conversation_sidebar-fragment;desc="issue_conversation_sidebar fragment";dur=50.922556,nginx;desc="NGINX";dur=1.38485,glb;desc="GLB";dur=101.471863
strict-transport-security: max-age=31536000; includeSubdomains; preload
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With, Accept,Accept-Encoding, Accept, X-Requested-With
x-content-type-options: nosniff
x-frame-options: deny
x-voltron-version: 321f992
x-xss-protection: 0
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=tLIfchYaT0NjnfAAUgMsp6S7cySqYa4qTMZG9DFXXv%2BjgpxHwA0uZtQ%2FLmhfQKfIdh%2BumrVAa9a7HyVll7MubKftsLTH1X3HKCQCRxpBBtPT60Ry6Z2j9nCAyfrnjCXGEeIRWfqADrYj2zCriCYo1OOj01za%2BeRfrYwev0AquwSgVZfxzoJzmWSW%2FxeVn5Wo13b7QOcOYyJvIEdBj%2FOwfX58A6spJlM8KvkmLTxmtQozk35ALvyOok2PLBVGGsSdabMHLHezYNreKQIU%2FKAiCw%3D%3D--6YjG5bpcRlSVPDE%2B--ykkvcnx8x55Y5iB%2FgYxaJQ%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1415556824.1753834438; Path=/; Domain=github.com; Expires=Thu, 30 Jul 2026 00:13:58 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Thu, 30 Jul 2026 00:13:58 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: BED2:36AD5A:1240C0:1B0A9C:688963C6
Not an issue just a way to import EF 6 EDMX tables and and renaming of the tables/fields · Issue #1331 · ErikEJ/EFCorePowerTools · GitHub
No one assignedNo projectsNo milestoneNone yetNo branches or pull requests
Skip to content
Navigation Menu
{{ message }}
-
-
Notifications
You must be signed in to change notification settings - Fork 323
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
Here is some code I wrote to quickly export the tables I was using in the old EF6 for the EFCorePowerTools:
Just simply provide the path to your edmx file from the original EF6 and this will create two files the rename and the table list you can copy and paste into the config json for the efpt.
using System.Xml.Serialization;
namespace ExportEDMXToJson.Model.Edmx
{
public class EFEdmx
{
[XmlElement]
public StorageModel? StorageModels { get; set; }
[XmlElement]
public ConceptualModel? ConceptualModels { get; set; }
[XmlElement]
public Mappings? Mappings { get; set; }
}
public class StorageModel
{
[XmlElement]
public Schema? Schema { get; set; }
}
public class ConceptualModel
{
[XmlElement]
public Schema? Schema { get; set; }
}
public class Mappings
{
[XmlElement]
public Mapping Mapping { get; set; }
}
public class Schema
{
[XmlAttribute]
public string Namespace { get; set; }
[XmlAttribute]
public string Provider { get; set; }
[XmlAttribute]
public string ProviderManifestToken { get; set; }
[XmlAttribute]
public string Alias { get; set; }
[XmlElement]
public List<EntityType> EntityType { get; set; }
[XmlElement]
public List<Association> Association { get; set; }
[XmlElement]
public List<Function> Function { get; set; }
[XmlElement]
public EntityContainer EntityContainer { get; set; }
}
public class EntityType
{
public EntityType()
{
//Doc = null;
}
[XmlAttribute]
public string? Name { get; set; }
[XmlElement]
public Key Key { get; set; }
[XmlElement]
public List<Property> Property { get; set; }
[XmlElement]
public List<NavigationProperty> NavigationProperty { get; set; }
}
public class Association
{
[XmlAttribute]
public string? Name { get; set; }
}
public class Function
{
[XmlAttribute]
public string? Name { get; set; }
}
public class Key
{
[XmlElement]
public List<PropertyRef> PropertyRef { get; set; }
}
public class PropertyRef
{
[XmlAttribute]
public string? Name { get; set; }
}
public class Property
{
[XmlAttribute]
public string? Name { get; set; }
[XmlAttribute]
public string? Type { get; set; }
[XmlAttribute]
public string? Nullable { get; set; }
[XmlAttribute]
public string? MaxLength { get; set; }
[XmlAttribute]
public string? Precision { get; set; }
[XmlAttribute]
public string? Scale { get; set; }
[XmlAttribute]
public string? StoreGeneratedPattern { get; set; }
[XmlAttribute]
public string? FixedLength { get; set; }
[XmlAttribute]
public string? Unicode { get; set; }
}
public class NavigationProperty
{
[XmlAttribute]
public string? Name { get; set; }
[XmlAttribute]
public string? Relationship { get; set; }
[XmlAttribute]
public string? FromRole { get; set; }
[XmlAttribute]
public string? ToRole { get; set; }
}
public class Mapping
{
[XmlAttribute]
public string Space { get; set; }
[XmlElement]
public EntityContainerMapping EntityContainerMapping { get; set; }
}
public class EntityContainerMapping
{
[XmlAttribute]
public string StorageEntityContainer { get; set; }
[XmlAttribute]
public string CdmEntityContainer { get; set; }
[XmlElement]
public List<EntitySetMapping> EntitySetMapping { get; set; }
}
public class EntitySetMapping
{
[XmlAttribute]
public string Name { get; set; }
public EntityTypeMapping EntityTypeMapping { get; set; }
}
public class EntityTypeMapping
{
[XmlAttribute]
public string TypeName { get; set; }
public MappingFragment MappingFragment { get; set; }
}
public class MappingFragment
{
[XmlAttribute]
public string StoreEntitySet { get; set; }
[XmlElement]
public List<ScalarProperty> ScalarProperty { get; set; }
}
public class ScalarProperty
{
[XmlAttribute]
public string Name { get; set; }
[XmlAttribute]
public string ColumnName { get; set; }
}
public class EntityContainer
{
[XmlAttribute]
public string Name { get; set; }
[XmlElement]
public List<EntitySet> EntitySet { get; set; }
}
public class EntitySet
{
[XmlAttribute]
public string Name { get; set; }
[XmlAttribute]
public string EntityType { get; set; }
[XmlAttribute]
public string Schema { get; set; }
[XmlAttribute]
public string storeSchema { get; set; }
[XmlAttribute]
public string storeType { get; set; }
public string TableName
{
get
{
return string.Format("[{0}].[{1}]", Schema ?? storeSchema, Name);
}
}
}
}
namespace ExportEDMXToJson.Model.EFTool
{
internal class EFTableList
{
public EFTool()
{
}
public EFTool(Edmx.EFEdmx edmx)
{
if (edmx?.StorageModels?.Schema != null)
{
Tables = edmx.StorageModels.Schema.EntityContainer.EntitySet.Select(s => new Table
{
Name = s.TableName,
ObjectType = s.storeType == "Table" ? 0 : 1,
}).ToList();
}
}
public int CodeGenerationMode { get; set; }
public string ContextClassName { get; set; }
public string ContextNamespace { get; set; }
public string DefaultDacpacSchema { get; set; }
public string FilterSchemas { get; set; }
public string IncludeConnectionString { get; set; }
public string ModelNamespace { get; set; }
public string OutputContextPath { get; set; }
public string OutputPath { get; set; }
public string ProjectRootNamespace { get; set; }
public List<Schema> Schemas { get; set; }
public int SelectedHandlebarsLanguage { get; set; }
public int SelectedToBeGenerated { get; set; }
public List<Table> Tables { get; set; }
}
public class Table
{
public string Name { get; set; }
public int ObjectType { get; set; }
}
public class Schema
{
public string Name { get; set; }
}
internal class EFRenameList
{
public EFRenameTool()
{
}
public EFRenameTool(Edmx.EFEdmx edmx)
{
var tables = edmx.Mappings.Mapping.EntityContainerMapping.EntitySetMapping.Select(s => new TableRename
{
NewName = s.Name,
Name = s.EntityTypeMapping.MappingFragment.StoreEntitySet,
Columns = s.EntityTypeMapping.MappingFragment.ScalarProperty.Select(col => new ColumnRename()
{
Name = col.ColumnName,
NewName = col.Name
}).ToList()
}).ToList();
var tableList = tables.Select(s => s.Name).ToList();
var schemaList = edmx.StorageModels.Schema.EntityContainer.EntitySet
.GroupBy(g => new { Schema = g.storeSchema ?? g.Schema })
.Select(s => new { Schema = s.Key.Schema, Tables = s.ToList() })
.ToList();
Schemas = new List<SchemaRename>();
foreach (var schema in schemaList)
{
Schemas.Add(new SchemaRename()
{
SchemaName = schema.Schema,
UseSchemaName = false,
Tables = tables.Where(f => tableList.Contains(f.Name)).ToList()
}); ;;
}
}
//public string SchemaName { get; set; }
//public bool UseSchemaName { get; set; }
//public List<TableRename> Tables { get; set; }
public List<SchemaRename> Schemas { get; set; }
}
public class SchemaRename
{
public string SchemaName { get; set; }
public bool UseSchemaName { get; set; }
public List<TableRename> Tables { get; set; }
}
public class TableRename
{
public List<ColumnRename> Columns { get; set; }
public string Name { get; set; }
public string NewName { get; set; }
}
public class ColumnRename
{
public string Name { get; set; }
public string NewName { get; set; }
}
}
public class ImportEF6TabletoEFCorePT
{
public void Convert(string pathToEDMX)
{
string text = File.ReadAllText(pathToEDMX);
text = text.Replace("edmx:", string.Empty);
text = text.Replace("xmlns:", string.Empty);
text = text.Replace("xmlns", "x");
text = text.Replace(":", string.Empty);
File.WriteAllText("temp.xml", text);
var reader = new ChoXmlReader<EFEdmx>("temp.xml");
EFEdmx rec = reader.Read();
if (rec.ConceptualModels != null)
{
var efTableList = new EFTableList(rec);
var efRenameList = new EFRenameList(rec);
var tableListJson = Newtonsoft.Json.JsonConvert.SerializeObject(efTableList, Formatting.Indented);
var renameList = Newtonsoft.Json.JsonConvert.SerializeObject(efRenameList, Formatting.Indented);
File.WriteAllText("efpt.tablelist.json", tableListJson);
File.WriteAllText("efpt.renaming.json", renameList);
}
reader.Close();
File.Delete("temp.xml");
}
}
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested
Projects
Milestone
Relationships
Development
Issue actions
You can’t perform that action at this time.