EntityFrameworkCore.Scaffolding.Handlebars: NullReferenceException in CheckOutputFiles

I’m using .NET Core 2.1.300-rc1-008673 and have updated to 1.0.0-rc3 of EntityFrameworkCore.Scaffolding.Handlebars. I get the following NullPointer when trying to scaffold from an existing database. I have previously used 1.0.0-beta together with .NET Core 2.0 and have successfully scaffolded using the same database.

Unable to generate entity type for table ‘dbo.SavedRadioButtons’. The column ‘dbo.NoteResources.IsActive’ would normally be mapped to a non-nullable bool property, but it has a default constraint. Such a column is mapped to a nullable bool property to allow a difference between setting the property to false and invoking the default constraint. See https://go.microsoft.com/fwlink/?linkid=851278 for details. System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.CheckOutputFiles(ScaffoldedModel scaffoldedModel, String outputDir, Boolean overwriteFiles) at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.Save(ScaffoldedModel scaffoldedModel, String outputDir, Boolean overwriteFiles) at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable1 schemas, IEnumerable1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable1 schemaFilters, IEnumerable1 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) Object reference not set to an instance of an object.

I’m using the following command:

dotnet ef dbcontext scaffold “Data Source=localhost;Initial Catalog=MyDatabase;User Id=secret; Password=secret” Microsoft.EntityFrameworkCore.SqlServer -o Domain -c MyDbContext -f

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 27 (15 by maintainers)

Most upvoted comments

To debug, add a call to Debugger.Launch() somewhere in your code, e.g. in your or the app’s IDesignTimeServices.ConfigureDesignTimeServices() implementation.