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.

Scaffold-DbContext does not emit warning messages for failed entity generation

See original GitHub issue

If table contains columns with UDDT, it can’t be exported and there is no log information why.

Steps to reproduce

Install Visual Studio 2017 RC1. Install MSSQL Server Express 2016. Create schema Users or remove it from code. In DB create simple UDDT: CREATE TYPE [Users].[UserName] FROM [nvarchar](20) NOT NULL And create simple table: CREATE TABLE [Users].[Users]( [UserId] [int] IDENTITY(1,1) NOT NULL, [UserName] [Users].[UserName] NOT NULL, CONSTRAINT [PK_Users.Users:UserId] PRIMARY KEY CLUSTERED ( [UserId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [UsersData] ) ON [UsersData] Next in VS2017RC1 command line: Scaffold-DbContext "Server=localhost\SQLEXPRESS; Database=SimpleDB; User Id=Test; Password=Test; MultipleActiveResultSets=true;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Data\Models\Users -Schema Users -Force -Verbose After this, we will receive:

[Table("Users", Schema = "Users")]
    public partial class Users
    {
        public long UserId { get; set; }
    }

Where is column UserName?! And this for all UDDT.

Key -Verbose in command parameters, but nothing output about this. If your table contains all columns with UDDT - you will receive empty log and simple string // Unable to generate entity type for table 'Users.Users'. Please see the warning messages. in Context.cs It mean - there is no any info\warnings\errors (it mean ok - isn’t it?) in command line with -Verbose key, but receive full zero in code.

Further technical details

<PackageReference Include="Microsoft.NETCore.App" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink.Loader" Version="14.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0-preview4-final" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.0.0-msbuild2-final" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0-msbuild2-final" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0-msbuild2-final" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0-msbuild2-final" />

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
bricelamcommented, Mar 2, 2017

Marking for re-triage. This (not showing log messages during Scaffold-DbContext) is a good candidate for 1.1.2.

0reactions
Axioma-ShirokovPNcommented, Apr 27, 2017

Yes, it works in aspnet-1-1-2-may2017-patch-public Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scaffold-DbContext does not emit warning messages for ...
When Scaffold-DbContext fails to generate an entity for a table it does not emit warning messages that describe why the generation failed.
Read more >
"Build failed" on Database First Scaffold-DbContext
A 'Build failed' message can occur for many reasons, but the dumbest would be if you don't have EFCore installed in the project...
Read more >
Learning EF - Error running Scaffold-DbContext
I am learning how to user Entity Framework where the models are built from an existing SQL server. I ran this command in...
Read more >
How To Fix Common Errors Using ASP.NET MVC Scaffolding
Error: There was an error running the selected code generator: Try rebuilding the project. If we get the following error message, we are...
Read more >
The dotnet dbcontext Scaffold ef and ...
I am trying to generate my models from the database using Entity framework via reverse engineering. but the command does not work.
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