IntelliTect / Coalesce

Quickly build amazing web apps
https://intellitect.github.io/Coalesce/
Apache License 2.0
64 stars 22 forks source link

Coalesce model validation fails when AppDbContext inherits from IdentityDbContext instead of DbContext #35

Closed caseybarsness closed 6 years ago

caseybarsness commented 6 years ago

When using this DbContext: public class AppDbContext : IdentityDbContext

Coalesce code generation fails with this error: System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.) ---> System.NullReferenceException: Object reference not set to an instance of an object. at IntelliTect.Coalesce.Validation.ValidateContext.Validate(ReflectionRepository repository) at IntelliTect.Coalesce.CodeGeneration.Generation.GenerationExecutor.<GenerateAsync>d__51.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at IntelliTect.Coalesce.Cli.Program.<>c__DisplayClass0_0.<<Main>b__1>d.MoveNext() --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) at IntelliTect.Coalesce.Cli.Program.Main(String[] args) ---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object. at IntelliTect.Coalesce.Validation.ValidateContext.Validate(ReflectionRepository repository) at IntelliTect.Coalesce.CodeGeneration.Generation.GenerationExecutor.<GenerateAsync>d__51.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at IntelliTect.Coalesce.Cli.Program.<>c__DisplayClass0_0.<<Main>b__1>d.MoveNext()<---

ascott18 commented 6 years ago

Funnily enough, you submitted this issue while the CI build for a fix for this issue was in progress. I happened to notice the exact same issue about 30 minutes prior. https://ci.appveyor.com/project/IntelliTect/coalesce/build/2.0.0-alpha-146

Fixed in e6a326c4f063c82fa5811fbdb1a9f75b7da9caa2, package version 2.0.0-alpha-148

caseybarsness commented 6 years ago

I have updated both nuget packages to 2.0.0-alpha-148 and still seem to be having the issue.

ascott18 commented 6 years ago

Ok, I'll take a look tomorrow hopefully.

ascott18 commented 6 years ago

(Did you make sure to update the tools package as well? There are three references in total to Coalesce packages across your projects. Two of them are in the web .csproj)

caseybarsness commented 6 years ago

I did not see the tools reference in web.csproj! I updated that and it fixed the issue!

Thank you!