Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Uses EF Core Power Tools by ErikEJ (see link in code) to creates a .DGML class diagram (and serves it up for saving) of most of the EntityFrameworkCore (EF Core 2) entities in the ASP.Net MVC project when you go to yourwebsite/dgml. This is useful because there is no Class Diagram support in .Net Core 2 yet and it is difficult to find any kind o…
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace CHANGEME.Api.Controllers
public class DgmlController : Controller
public CHANGEMEDbContext _context { get; }
public DgmlController( CHANGEMEDbContext context)
_context = context;
/// <summary>
/// Creates a DGML class diagram of most of the entities in the project wher you go to localhost/dgml
/// See
/// </summary>
/// <returns>a DGML class diagram</returns>
public IActionResult Get()
System.IO.File.WriteAllText(Directory.GetCurrentDirectory() + "\\Entities.dgml",
var file = System.IO.File.OpenRead(Directory.GetCurrentDirectory() + "\\Entities.dgml");
var response = File(file, "application/octet-stream", "Entities.dgml");
return response;

This comment has been minimized.

Copy link

alen12345 commented Jan 18, 2018

Very useful and perfectly working! Many thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.