You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CREATETABLEBlogs (Id int IDENTITY CONSTRAINT [PK_Blogs] PRIMARY KEY,)
go
CREATETABLEPosts (Id int IDENTITY CONSTRAINT [PK_Posts] PRIMARY KEY,)
go
CREATETABLEBlogPosts (
BlogId intNOT NULLCONSTRAINT [FK_BlogPosts_Blogs] REFERENCES Blogs ON DELETE CASCADE,
PostId intNOT NULLCONSTRAINT [FK_BlogPosts_Posts] REFERENCES Posts ON DELETE CASCADE,
-- No Primary key
)
go
When scaffolding in EF7, scaffolding will fail due to a crash
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpDbContextGenerator.TransformText()
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpModelGenerator.ProcessTemplate(ITextTransformationtransformation)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpModelGenerator.GenerateModel(IModelmodel,ModelCodeGenerationOptionsoptions)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(StringconnectionString,DatabaseModelFactoryOptionsdatabaseOptions,ModelReverseEngineerOptionsmodelOptions,ModelCodeGenerationOptionscodeOptions)
at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(Stringprovider,StringconnectionString,StringoutputDir,StringoutputContextDir,StringdbContextClassName, IEnumerable`1schemas, IEnumerable`1tables,StringmodelNamespace,StringcontextNamespace,BooleanuseDataAnnotations,BooleanoverwriteFiles,BooleanuseDatabaseNames,BooleansuppressOnConfiguring,BooleannoPluralize)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(Stringprovider,StringconnectionString,StringoutputDir,StringoutputDbContextDir,StringdbContextClassName, IEnumerable`1schemaFilters, IEnumerable`1tableFilters,StringmodelNamespace,StringcontextNamespace,BooleanuseDataAnnotations,BooleanoverwriteFiles,BooleanuseDatabaseNames,BooleansuppressOnConfiguring,BooleannoPluralize)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Actionaction)
Object reference not set to an instance of an object.
When adding a Primary Key to the Table the configuration will be generated again
Assume the following database
When scaffolding in EF7, scaffolding will fail due to a crash
When adding a Primary Key to the Table the configuration will be generated again
EF Core version: 7.0
Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer)
Target framework: (e.g. .NET 7.0)
Operating system:
IDE: (e.g. Visual Studio 2022 17.4)
The text was updated successfully, but these errors were encountered: