question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EF Core Power Tool for VS 2019 cannot add dbcontext diagram

See original GitHub issue

The tool threw exceptions when I attempted to add a dbcontext diagram in Visual Studio 2019 16.4.1 for EF Core 2.2.

Exception message: ` System.NotSupportedException: The given path’s format is not supported. at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream…ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost) at System.IO.StreamWriter…ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost) at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost) at System.IO.File.WriteAllText(String path, String contents, Encoding encoding) at EFCorePowerTools.Handlers.ModelAnalyzerHandler.GenerateDgml(String processResult, Project project) in C:\projects\efcorepowertools\src\GUI\EFCorePowerTools\Handlers\ModelAnalyzerHandler.cs:line 122 at EFCorePowerTools.Handlers.ModelAnalyzerHandler.Generate(String outputPath, Project project, GenerationType generationType) in C:\projects\efcorepowertools\src\GUI\EFCorePowerTools\Handlers\ModelAnalyzerHandler.cs:line 80

`

Steps to reproduce

  1. In VS 2019, right-click on the project that contains the dbcontext
  2. Select EF Core Power Tools
  3. Select Add DbContext Model Diagram

Further technical details

EF Core Power Tools version: 2.3.92.0

Database engine: MS SQL Server

Visual Studio version: Visual Studio 2019 16.4.1 EFCorePowerTools-Exceptions

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:27 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
ErikEJcommented, Jan 27, 2020

I have attempted a fix in the latest daily build

1reaction
stefankipcommented, Jan 27, 2020

So yeah this is the complete string used for the Path.Combine method:

"C:\\Users\\Stefan\\AppData\\Local\\Temp\\dbug: Microsoft.EntityFrameworkCore.Infrastructure[10401]\r\n      An 'IServiceProvider' was created for internal use by Entity Framework.\r\ninfo: Microsoft.EntityFrameworkCore.Infrastructure[10403]\r\n      Entity Framework Core 3.1.1 initialized 'MarketIntelligenceContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None.dgml"

I guess that’s not going to work at all 😉

This is the value of the modelResult argument:

{
    "$type": "System.Collections.Generic.List<System.Tuple<string, string>>",
    "$values": [
        {
            "$type": "System.Tuple<string, string>",
            "m_Item1": "dbug: Microsoft.EntityFrameworkCore.Infrastructure[10401]\r\n      An 'IServiceProvider' was created for internal use by Entity Framework.\r\ninfo: Microsoft.EntityFrameworkCore.Infrastructure[10403]\r\n      Entity Framework Core 3.1.1 initialized 'MarketIntelligenceContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None",
            "m_Item2": "",
            "Item1": "dbug: Microsoft.EntityFrameworkCore.Infrastructure[10401]\r\n      An 'IServiceProvider' was created for internal use by Entity Framework.\r\ninfo: Microsoft.EntityFrameworkCore.Infrastructure[10403]\r\n      Entity Framework Core 3.1.1 initialized 'MarketIntelligenceContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None",
            "Item2": "",
            "System.Runtime.CompilerServices.ITuple.Length": 2
        },
        {
            "$type": "System.Tuple<string, string>",
            "m_Item1": "MarketIntelligenceContext",
            "m_Item2": "Model: \r\n  EntityType: Country\r\n    Properties: \r\n      ID (int) Required PK AfterSave:Throw ValueGenerated.OnAdd\r\n        Annotations: \r\n          SqlServer:ValueGenerationStrategy: IdentityColumn\r\n          TypeMapping: Microsoft.EntityFrameworkCore.Storage.IntTypeMapping\r\n      Created (DateTimeOffset) Required\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n      Deleted (Nullable<DateTimeOffset>) Index\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n      Name (string)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerStringTypeMapping\r\n      Updated (Nullable<DateTimeOffset>)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n    Keys: \r\n      ID PK\r\n    Annotations: \r\n      ConstructorBinding: Microsoft.EntityFrameworkCore.Metadata.ConstructorBinding\r\n      Relational:TableName: Country\r\n  EntityType: NewsItem\r\n    Properties: \r\n      ID (int) Required PK AfterSave:Throw ValueGenerated.OnAdd\r\n        Annotations: \r\n          SqlServer:ValueGenerationStrategy: IdentityColumn\r\n          TypeMapping: Microsoft.EntityFrameworkCore.Storage.IntTypeMapping\r\n      Body (string)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerStringTypeMapping\r\n      Created (DateTimeOffset) Required\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n      Creator (string)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerStringTypeMapping\r\n      Deleted (Nullable<DateTimeOffset>) Index\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n      Slug (string) Index\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerStringTypeMapping\r\n      Title (string)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerStringTypeMapping\r\n      Updated (Nullable<DateTimeOffset>)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n    Keys: \r\n      ID PK\r\n    Annotations: \r\n      ConstructorBinding: Microsoft.EntityFrameworkCore.Metadata.ConstructorBinding\r\n      Relational:TableName: NewsItem\r\n  EntityType: SalesGroup\r\n    Properties: \r\n      ID (int) Required PK AfterSave:Throw ValueGenerated.OnAdd\r\n        Annotations: \r\n          SqlServer:ValueGenerationStrategy: IdentityColumn\r\n          TypeMapping: Microsoft.EntityFrameworkCore.Storage.IntTypeMapping\r\n      Created (DateTimeOffset) Required\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n      Deleted (Nullable<DateTimeOffset>) Index\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n      Name (string)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerStringTypeMapping\r\n      Updated (Nullable<DateTimeOffset>)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n    Keys: \r\n      ID PK\r\n    Annotations: \r\n      ConstructorBinding: Microsoft.EntityFrameworkCore.Metadata.ConstructorBinding\r\n      Relational:TableName: SalesGroup\r\n  EntityType: VehiclePlant\r\n    Properties: \r\n      ID (int) Required PK AfterSave:Throw ValueGenerated.OnAdd\r\n        Annotations: \r\n          SqlServer:ValueGenerationStrategy: IdentityColumn\r\n          TypeMapping: Microsoft.EntityFrameworkCore.Storage.IntTypeMapping\r\n      Created (DateTimeOffset) Required\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n      Deleted (Nullable<DateTimeOffset>) Index\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n      Name (string)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerStringTypeMapping\r\n      SoldToID (int) Required Index\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.Storage.IntTypeMapping\r\n      Updated (Nullable<DateTimeOffset>)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n    Keys: \r\n      ID PK\r\n    Annotations: \r\n      ConstructorBinding: Microsoft.EntityFrameworkCore.Metadata.ConstructorBinding\r\n      Relational:TableName: VehiclePlant\r\nAnnotations: \r\n  ProductVersion: 3.1.1\r\n  Relational:MaxIdentifierLength: 128\r\n  SqlServer:ValueGenerationStrategy: IdentityColumn",
            "Item1": "MarketIntelligenceContext",
            "Item2": "Model: \r\n  EntityType: Country\r\n    Properties: \r\n      ID (int) Required PK AfterSave:Throw ValueGenerated.OnAdd\r\n        Annotations: \r\n          SqlServer:ValueGenerationStrategy: IdentityColumn\r\n          TypeMapping: Microsoft.EntityFrameworkCore.Storage.IntTypeMapping\r\n      Created (DateTimeOffset) Required\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n      Deleted (Nullable<DateTimeOffset>) Index\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n      Name (string)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerStringTypeMapping\r\n      Updated (Nullable<DateTimeOffset>)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n    Keys: \r\n      ID PK\r\n    Annotations: \r\n      ConstructorBinding: Microsoft.EntityFrameworkCore.Metadata.ConstructorBinding\r\n      Relational:TableName: Country\r\n  EntityType: NewsItem\r\n    Properties: \r\n      ID (int) Required PK AfterSave:Throw ValueGenerated.OnAdd\r\n        Annotations: \r\n          SqlServer:ValueGenerationStrategy: IdentityColumn\r\n          TypeMapping: Microsoft.EntityFrameworkCore.Storage.IntTypeMapping\r\n      Body (string)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerStringTypeMapping\r\n      Created (DateTimeOffset) Required\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n      Creator (string)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerStringTypeMapping\r\n      Deleted (Nullable<DateTimeOffset>) Index\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n      Slug (string) Index\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerStringTypeMapping\r\n      Title (string)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerStringTypeMapping\r\n      Updated (Nullable<DateTimeOffset>)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n    Keys: \r\n      ID PK\r\n    Annotations: \r\n      ConstructorBinding: Microsoft.EntityFrameworkCore.Metadata.ConstructorBinding\r\n      Relational:TableName: NewsItem\r\n  EntityType: SalesGroup\r\n    Properties: \r\n      ID (int) Required PK AfterSave:Throw ValueGenerated.OnAdd\r\n        Annotations: \r\n          SqlServer:ValueGenerationStrategy: IdentityColumn\r\n          TypeMapping: Microsoft.EntityFrameworkCore.Storage.IntTypeMapping\r\n      Created (DateTimeOffset) Required\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n      Deleted (Nullable<DateTimeOffset>) Index\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n      Name (string)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerStringTypeMapping\r\n      Updated (Nullable<DateTimeOffset>)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n    Keys: \r\n      ID PK\r\n    Annotations: \r\n      ConstructorBinding: Microsoft.EntityFrameworkCore.Metadata.ConstructorBinding\r\n      Relational:TableName: SalesGroup\r\n  EntityType: VehiclePlant\r\n    Properties: \r\n      ID (int) Required PK AfterSave:Throw ValueGenerated.OnAdd\r\n        Annotations: \r\n          SqlServer:ValueGenerationStrategy: IdentityColumn\r\n          TypeMapping: Microsoft.EntityFrameworkCore.Storage.IntTypeMapping\r\n      Created (DateTimeOffset) Required\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n      Deleted (Nullable<DateTimeOffset>) Index\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n      Name (string)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerStringTypeMapping\r\n      SoldToID (int) Required Index\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.Storage.IntTypeMapping\r\n      Updated (Nullable<DateTimeOffset>)\r\n        Annotations: \r\n          TypeMapping: Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeOffsetTypeMapping\r\n    Keys: \r\n      ID PK\r\n    Annotations: \r\n      ConstructorBinding: Microsoft.EntityFrameworkCore.Metadata.ConstructorBinding\r\n      Relational:TableName: VehiclePlant\r\nAnnotations: \r\n  ProductVersion: 3.1.1\r\n  Relational:MaxIdentifierLength: 128\r\n  SqlServer:ValueGenerationStrategy: IdentityColumn",
            "System.Runtime.CompilerServices.ITuple.Length": 2
        }
    ]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

EF Core Power Tools EntityFrameworkCore.Design. ...
EF Core Power Tools EntityFrameworkCore.Design.OperationException suddenly occurring on "Add DbContext Diagram" · 1. You have to run the Tool ...
Read more >
EF Core Power Tool for VS 2019 cannot add dbcontext ...
In VS 2019, right-click on the project that contains the dbcontext · Select EF Core Power Tools · Select Add DbContext Model Diagram...
Read more >
EF Core Power Tools
Migrations Tool - Manage EF Core Migrations in the project, ... Add DbContext Model Diagram - Adds a DGML graph from your DbContext...
Read more >
Using EF Core - Power Tools In ASP.NET Core API
In this article, we will learn how to integrate EF Core power tools and its usage to generate POCO Classes in Core API....
Read more >
Scaffolding (Reverse Engineering) - EF Core
These tools provide a graphical tool which builds on top of the EF Core command line tools and offers additional workflow and customization ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found