C++ UserWidget instance with an UPROPERTY doesn't compile

I have this variable

	TSubclassOf<UUserWidget> WidgetTemplate;

This is the error that I get when trying to compile my project

error LNK2019: unresolved external symbol "__declspec(dllimport) class UClass * __cdecl Z_Construct_UClass_UUserWidget_NoRegister(void)" (__imp_?Z_Construct_UClass_UUserWidget_NoRegister@@YAPEAVUClass@@XZ) referenced in function "class UClass * __cdecl Z_Construct_UClass_AProjectEgeriaCharacter(void)" (?Z_Construct_UClass_AProjectEgeriaCharacter@@YAPEAVUClass@@XZ)

The project does compile when I remove the UPROPERTY. Including UserWidget does not help the situation. Am I doing something wrong?

I am facing this problem too, can anyone help?

You need to add UMG module to dependencies in *.Build.cs file of your module, there should be list indie of moduelsl ike Enigne, Core etc. Just add UMG. Also add Slate and SlateCore as UMG APIs use code from those modules too