Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaffold-DbContext PMC Command doesn't work (Bug) #15414

Closed
Yuant-tobing opened this issue Apr 19, 2019 · 28 comments · Fixed by #15428
Closed

Scaffold-DbContext PMC Command doesn't work (Bug) #15414

Yuant-tobing opened this issue Apr 19, 2019 · 28 comments · Fixed by #15428
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Milestone

Comments

@Yuant-tobing
Copy link

Reverse engineer doesn't work and displays an error message on the console.

PMC Command:

Scaffold-DbContext "Server=YUANT;Database=NetAntiError;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

If you are seeing an exception, include the full exceptions details (message and stack trace).

System.InvalidCastException: Unable to cast object of type 'Microsoft.EntityFrameworkCore.Diagnostics.RelationalLoggingDefinitions' to type 'Microsoft.EntityFrameworkCore.SqlServer.Diagnostics.Internal.SqlServerLoggingDefinitions'.
   at Microsoft.EntityFrameworkCore.SqlServer.Internal.SqlServerResources.LogFoundDefaultSchema(IDiagnosticsLogger logger)
   at Microsoft.EntityFrameworkCore.SqlServer.Internal.SqlServerLoggerExtensions.DefaultSchemaFound(IDiagnosticsLogger`1 diagnostics, String schemaName)
   at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.GetDefaultSchema(DbConnection connection)
   at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(DbConnection connection, DatabaseModelFactoryOptions options)
   at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(String connectionString, DatabaseModelFactoryOptions options)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, DatabaseModelFactoryOptions options, String rootNamespace, String modelNamespace, String contextNamespace, String language, String contextDir, String contextName, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
   at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_1.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Unable to cast object of type 'Microsoft.EntityFrameworkCore.Diagnostics.RelationalLoggingDefinitions' to type 'Microsoft.EntityFrameworkCore.SqlServer.Diagnostics.Internal.SqlServerLoggingDefinitions'.

Steps to reproduce

  • Create a new ASP NET Core project.
  • Add Microsoft.EntityFrameworkCore.SqlServer
  • Add Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite
  • Add Microsoft.EntityFrameworkCore.Tools
  • Add connection string on appsettings.json
{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  "ConnectionStrings": {
    "DefaultConnection": "Server=YUANT;Database=NetAntiError;Trusted_Connection=True;MultipleActiveResultSets=true"
  }
}

In the previous version, a procedure like this still works. Am I missing something?

Further technical details

EF Core version: 3.0.0-preview4.19216.3
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Ms. Windows 10
IDE: Visual Studio 2019 16.0.2

@ErikEJ
Copy link
Contributor

ErikEJ commented Apr 19, 2019

Pls share your csproj file contents

@ajcvickers
Copy link
Member

ajcvickers commented Apr 19, 2019

Note for triage: I was able to reproduce this. //cc @bricelam @divega

Additional info:

  • Tried on RTM VS; didn't try on preview VS, which is recommended
  • Switched on .NET Core previews in VS
  • Created a .NET Core 3.0 ASP.NET Core app, with no auth

Stack:

PM> Scaffold-DbContext "Server=(localdb)\mssqllocaldb;Database=Test;ConnectRetryCount=0" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
System.InvalidCastException: Unable to cast object of type 'Microsoft.EntityFrameworkCore.Diagnostics.RelationalLoggingDefinitions' to type 'Microsoft.EntityFrameworkCore.SqlServer.Diagnostics.Internal.SqlServerLoggingDefinitions'.
   at Microsoft.EntityFrameworkCore.SqlServer.Internal.SqlServerResources.LogFoundDefaultSchema(IDiagnosticsLogger logger)
   at Microsoft.EntityFrameworkCore.SqlServer.Internal.SqlServerLoggerExtensions.DefaultSchemaFound(IDiagnosticsLogger`1 diagnostics, String schemaName)
   at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.GetDefaultSchema(DbConnection connection)
   at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(DbConnection connection, DatabaseModelFactoryOptions options)
   at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(String connectionString, DatabaseModelFactoryOptions options)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, DatabaseModelFactoryOptions options, String rootNamespace, String modelNamespace, String contextNamespace, String language, String contextDir, String contextName, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
   at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_1.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Unable to cast object of type 'Microsoft.EntityFrameworkCore.Diagnostics.RelationalLoggingDefinitions' to type 'Microsoft.EntityFrameworkCore.SqlServer.Diagnostics.Internal.SqlServerLoggingDefinitions'.
PM> 

csproj:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <AddRazorSupportForMvc>true</AddRazorSupportForMvc>
  </PropertyGroup>


  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0-preview4-19216-03" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview4.19216.3" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite" Version="3.0.0-preview4.19216.3" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0-preview4.19216.3">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

</Project>

@ajcvickers ajcvickers self-assigned this Apr 19, 2019
@ajcvickers ajcvickers added this to the 3.0.0 milestone Apr 19, 2019
@emre1702
Copy link

Got the same problem:

Scaffold-DbContext "Data Source=[LinuxIP];database=[DB];user id=SA;password=[PW];" Microsoft.EntityFrameworkCore.SqlServer -o %~dp0Entity -f

System.InvalidCastException: Unable to cast object of type 'Microsoft.EntityFrameworkCore.Diagnostics.RelationalLoggingDefinitions' to type 'Microsoft.EntityFrameworkCore.SqlServer.Diagnostics.Internal.SqlServerLoggingDefinitions'.
   at Microsoft.EntityFrameworkCore.SqlServer.Internal.SqlServerResources.LogFoundDefaultSchema(IDiagnosticsLogger logger)
   at Microsoft.EntityFrameworkCore.SqlServer.Internal.SqlServerLoggerExtensions.DefaultSchemaFound(IDiagnosticsLogger`1 diagnostics, String schemaName)
   at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.GetDefaultSchema(DbConnection connection)
   at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(DbConnection connection, DatabaseModelFactoryOptions options)
   at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(String connectionString, DatabaseModelFactoryOptions options)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, DatabaseModelFactoryOptions options, String rootNamespace, String modelNamespace, String contextNamespace, String language, String contextDir, String contextName, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
   at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_1.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)

csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0-preview4.19216.3" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="3.0.0-preview4.19216.3" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.0-preview4.19216.3">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview4.19216.3" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0-preview4.19216.3">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="System.Configuration.ConfigurationManager" Version="4.6.0-preview4.19212.13" />
  </ItemGroup>

</Project>

@Yuant-tobing
Copy link
Author

Pls share your csproj file contents

This is my csproj:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <LangVersion>8.0</LangVersion>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0-preview4-19216-03" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview4.19216.3" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite" Version="3.0.0-preview4.19216.3" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0-preview4.19216.3">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

</Project>

My IDE version: (RTM)

Microsoft Visual Studio Enterprise 2019
Version 16.0.2
VisualStudio.16.Release/16.0.2+28803.202
Microsoft .NET Framework
Version 4.7.03190

Installed Version: Enterprise

Architecture Diagrams and Analysis Tools   00435-60000-00000-AA566
Microsoft Architecture Diagrams and Analysis Tools

Application Insights Tools for Visual Studio Package   9.0.20307.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2019   16.0.12311.10635
ASP.NET and Web Tools 2019

ASP.NET Web Frameworks and Tools 2019   16.0.12311.10635
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   16.0.12311.10635
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools   16.0.12311.10635
Azure Functions and Web Jobs Tools

C# Tools   3.0.0-beta4-19170-01+1deafee3682da88bf07d1c18521a99f47446cee8
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus   1.1.77 (master@24013d5)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 0x10 - v2.9.0.0

Microsoft Continuous Delivery Tools for Visual Studio   0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager   1.0
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers   1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Mono Debugging for Visual Studio   16.0.300 (573eda3)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   5.0.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension   1.0
ResourcePackage Visual Studio Extension Detailed Info

ResourcePackage Extension   1.0
ResourcePackage Visual Studio Extension Detailed Info

Snapshot Debugging Extension   1.0
Snapshot Debugging Visual Studio Extension Detailed Info

SQL Server Data Tools   16.0.61903.25110
Microsoft SQL Server Data Tools

TypeScript Tools   16.0.10306.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   3.0.0-beta4-19170-01+1deafee3682da88bf07d1c18521a99f47446cee8
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.4 for F# 4.6   16.0.0.0.  Commit Hash: 809f41207b74a1356208f11b8fa3a15233734050.
Microsoft Visual F# Tools 10.4 for F# 4.6

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Containers   1.0
Visual Studio Tools for Containers

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

Xamarin   16.0.0.515 (d16-0@a3502d929)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   4.17.4.418 (remotes/origin/d16-0@3d086e814)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates   16.1.47 (31f664d)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK   9.2.0.5 (HEAD/292d27fa)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: mono/mono/2018-08-rc@5ad371dab1b
    Java.Interop: xamarin/java.interop/d16-0@c987483
    LibZipSharp: grendello/LibZipSharp/master@44de300
    LibZip: nih-at/libzip/rel-1-5-1@b95cf3f
    MXE: xamarin/mxe/xamarin@b9cbb535
    ProGuard: xamarin/proguard/master@905836d
    SQLite: xamarin/sqlite/3.26.0@325e91a
    Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-0@0a7edd6


Xamarin.iOS and Xamarin.Mac SDK   12.8.0.0 (0aa8452)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

@Yuant-tobing
Copy link
Author

Note for triage: I was able to reproduce this. //cc @bricelam @divega

Additional info:

  • Tried on RTM VS; didn't try on preview VS, which is recommended
  • Switched on .NET Core previews in VS
  • Created a .NET Core 3.0 ASP.NET Core app, with no auth

Stack:

PM> Scaffold-DbContext "Server=(localdb)\mssqllocaldb;Database=Test;ConnectRetryCount=0" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
System.InvalidCastException: Unable to cast object of type 'Microsoft.EntityFrameworkCore.Diagnostics.RelationalLoggingDefinitions' to type 'Microsoft.EntityFrameworkCore.SqlServer.Diagnostics.Internal.SqlServerLoggingDefinitions'.
   at Microsoft.EntityFrameworkCore.SqlServer.Internal.SqlServerResources.LogFoundDefaultSchema(IDiagnosticsLogger logger)
   at Microsoft.EntityFrameworkCore.SqlServer.Internal.SqlServerLoggerExtensions.DefaultSchemaFound(IDiagnosticsLogger`1 diagnostics, String schemaName)
   at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.GetDefaultSchema(DbConnection connection)
   at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(DbConnection connection, DatabaseModelFactoryOptions options)
   at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(String connectionString, DatabaseModelFactoryOptions options)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, DatabaseModelFactoryOptions options, String rootNamespace, String modelNamespace, String contextNamespace, String language, String contextDir, String contextName, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
   at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_1.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Unable to cast object of type 'Microsoft.EntityFrameworkCore.Diagnostics.RelationalLoggingDefinitions' to type 'Microsoft.EntityFrameworkCore.SqlServer.Diagnostics.Internal.SqlServerLoggingDefinitions'.
PM> 

csproj:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <AddRazorSupportForMvc>true</AddRazorSupportForMvc>
  </PropertyGroup>


  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0-preview4-19216-03" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview4.19216.3" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite" Version="3.0.0-preview4.19216.3" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0-preview4.19216.3">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

</Project>

@ajcvickers ,, I did it exactly as you suggested. The difference is only in the csproj configuration, I created a project API, so I don't need to add this script:

<AddRazorSupportForMvc>true</AddRazorSupportForMvc>

ajcvickers added a commit that referenced this issue Apr 21, 2019
By making the base classes abstract and never registering them as defaults in D.I.

Fixes #15414
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Apr 21, 2019
ajcvickers added a commit that referenced this issue Apr 21, 2019
By making the base classes abstract and never registering them as defaults in D.I.

Fixes #15414
@myblindy
Copy link

Is there a fix for this? I have the same issue by just creating a stock VS2019 ASP Net MVC Core 3.0 preview project and trying to scaffold a database first model.

@ajcvickers
Copy link
Member

ajcvickers commented Apr 22, 2019

@myblindy It is fixed for next preview. You could try the nightly builds using the feeds listed on the homepaage if you need the fix before then. However, note that the fix may not yet have propagated to the nightlies.

@ajcvickers ajcvickers modified the milestones: 3.0.0, 3.0.0-preview5 Apr 22, 2019
@PeaStew
Copy link

PeaStew commented Apr 23, 2019

Oh this is pain... manually creating scaffolding takes me back to the day (last week) when I was manually fixing EF6 entries for Oracle database entities... latest preview 5 still broken.

@guidevnet
Copy link

guidevnet commented Apr 24, 2019

Yes, Scaffold-DbContext is totally broken right now, without any possible workaround (except by using nightly builds). However, in the preview 5 milestone roadmap, all the issues are closed. Can I assume that Preview 5 will be released in the next few days? Or only in the next month as usual?

@ajcvickers
Copy link
Member

@guidevnet I can't say anything about when preview5 will be released even though we have branched for it.

@ErikEJ
Copy link
Contributor

ErikEJ commented Apr 25, 2019

@guidevnet Maybe in connection with an upcoming event?

@guidevnet
Copy link

guidevnet commented Apr 25, 2019

@ErikEJ You mean //build/? This actually makes a lot of sense. If so, there is 10+ days of wait. I'm crying right now... welp, let's try some nightly builds...

@ajcvickers
Copy link
Member

@guidevnet I'd be interested more in knowing how you're using the previews that makes this a long wait, and yet at the same time the nightlies are not an option. (I'm not trying to imply you're doing something wrong, but it's an unusual position and I would like to understand it better so we can make sure we're doing the right thing with previews.)

@guidevnet
Copy link

guidevnet commented Apr 25, 2019

@ajcvickers Yes, you are doing the right thing with previews - this is my fault. My team is developing a software to be released around October, and I choose to implement in .Net Core 3 (of course assuming that we would get some breaking changes along the road).

@ajcvickers
Copy link
Member

@guidevnet Thanks for the info.

@PeaStew
Copy link

PeaStew commented Apr 25, 2019

I'm in the same position, pushed Blazor onto my team for a software release in late October but little issues like this make it difficult, using nightlies makes early UAT complicated when you don't know what will break when, only that something will break :)

@guidevnet
Copy link

guidevnet commented Apr 25, 2019

@PeaStew Yeah, me too using blazor! (server-side). Ha, this is Microsoft's fault: if the new products where less awesome, we wouldn't bother using EF6 and MVC.

@PeaStew
Copy link

PeaStew commented Apr 25, 2019

@PeaStew Yeah, me too using blazor! (server-side). Ha, this is Microsoft's fault: if the new products where less awesome, we wouldn't bother using EF6 and MVC.

100%... I'm back to being a full-stack developer again, I was pushing all the Javascript off to team members because I hate it so much ;)

@skwork34
Copy link

skwork34 commented May 14, 2019

I'm trying to get preview5 working due to this error, but can't get that working either. I'm working on a fresh project file (I've tried 7 variants today) to post in a bit.

@ajcvickers
Copy link
Member

@jbrown-jane-com Can you post you csproj file?

@ErikEJ
Copy link
Contributor

ErikEJ commented May 14, 2019

Please post your csproj file...

@skwork34
Copy link

Here is my version 4 project that gives me the same errors listed in this feed. no suprises of course.

TestEF8-Version4.zip

Here is my version 5 project that has build errors (listed below).

TestEF8-Version5-BuildErrors.zip

Here are the errors:

Severity Code Description Project File Line Suppression State
Error NU1605 Detected package downgrade: Microsoft.NETCore.Platforms from 3.0.0-preview5.19224.8 to 3.0.0-preview4.19212.13. Reference the package directly from the project to select a different version.
TestEF8 -> Microsoft.EntityFrameworkCore.SqlServer 3.0.0-preview5.19227.1 -> System.Data.SqlClient 4.7.0-preview5.19224.8 -> System.Text.Encoding.CodePages 4.6.0-preview5.19224.8 -> Microsoft.NETCore.Platforms (>= 3.0.0-preview5.19224.8)
TestEF8 -> Microsoft.NETCore.Platforms (>= 3.0.0-preview4.19212.13) TestEF8 C:\Users\jbrown\source\repos\TestEF8\TestEF8\TestEF8.csproj 1
Error NU1605 Detected package downgrade: Microsoft.NETCore.Platforms from 3.0.0-preview5.19224.8 to 3.0.0-preview4.19212.13. Reference the package directly from the project to select a different version.
TestEF8 -> Microsoft.EntityFrameworkCore.SqlServer 3.0.0-preview5.19227.1 -> System.Data.SqlClient 4.7.0-preview5.19224.8 -> Microsoft.Win32.Registry 4.6.0-preview5.19224.8 -> System.Security.AccessControl 4.6.0-preview5.19224.8 -> Microsoft.NETCore.Platforms (>= 3.0.0-preview5.19224.8)
TestEF8 -> Microsoft.NETCore.Platforms (>= 3.0.0-preview4.19212.13) TestEF8 C:\Users\jbrown\source\repos\TestEF8\TestEF8\TestEF8.csproj 1

@skwork34
Copy link

Please keep in mind I have tried many variants of this. Starting with version5, starting with 4 and upgrading, using packagereferences, using install from package manager console. I have yet to get all the preview5 packages to work together. Hence my request for simple steps to get EF working with preview5.

@skwork34
Copy link

Interesting to note that my preview5 version of the project has all 5's in the project file but I get this:

image

You will note that the last NuGet package DotNetAppHost does not show preview5 even though I ran the install tool and put in the package ref. It keeps getting changed back when I install Platforms release5 or SqlServer release5.

Hopefully that gives you enough info.

@skwork34
Copy link

The project has nothing confidential in it, I can upload the entire folder if need be.

@guidevnet
Copy link

guidevnet commented May 14, 2019

@skwork34 You should try uninstalling all nuget packages, and then install all from scratch in version 5 (instead of upgrading it). The last package of your nuget folder is in preview 4, it seems like a dependency of other packages.

@skwork34
Copy link

skwork34 commented May 14, 2019

I've done that. That's the first route I took. It dies on installing the Microsoft.EntityFrameworkCore.SqlServer. That one gives the same error. But I can try again. Test #9 coming up. haha :) Thanks to all who looked at it.

I have no doubt it is just some wrong step I take. Is there anyone out there that has preview5 working from a scratch project that does scaffolding of an existing db? Did you use package manager to install, the manager console and install commands, or did you simply add PackageReferences in the project file? Any ideas would help. :)

@skwork34
Copy link

Found the issue: I mistakenly thought the latest update of visual studio that hit with the preview5 announcment had the preview5 .net core sdk with it. @guidevnet 's comment triggered the thought of downloading the sdk again and installing it and wham, it all works. Thanks for the triggering suggestion, and thanks to all who helped.

@ajcvickers ajcvickers modified the milestones: 3.0.0-preview5, 3.0.0 Nov 11, 2019
@ajcvickers ajcvickers removed their assignment Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants