I have completed following the tutorial at: Tutorial: Create a Razor Pages web app with ASP.NET Core
After finishing it I decided to add Reviews to the Movies (just to learn). As such I added a new Review class to my Models folder:
public class Review
{
public int ID { get; set; }
//[StringLength(50, ErrorMessage = "The Title must be less than {1} characters.")]
[StringLength(60, MinimumLength = 3)]
[Required]
public string Title { get; set; }
public string Description { get; set; }
[Range(1, 5)]
public int Rating { get; set; }
}
Then inside my 'Pages' folder I created a new one called 'Reviews' and I right-clicked -> Add -> New scaffolded Item. After selecting Razor Pages using Entity Framework (CRUD) I added the following details as seen on the picture:
My problem is that after VS generates the appropriate code, the application does not compile because it gives decades of errors like:
Error CS0229 Ambiguity between 'CreateModel._context' and 'CreateModel._context' RazorPagesMovie
Can someone please let me know of why that error is popping up?
Edit: After the scaffolding I observed that I have same file names (and classes on my solution). For example I have the CreateModel class that was auto-generated by scaffolding declared twice (once for the Movies & once for the Reviews):
Edit 2: It seems that both CreateModel classes (for Movies & Reviews) have exactly the same namespace (namespace RazorPagesMovie). Shouldn't they be something like: namespace RazorPagesMovie.Pages.Movies and namespace RazorPagesMovie.Pages.Reviews accordingly?
Apparently there is a known problem in Visual Studio that while Scaffolding the namespace is not generated correctly.
Links: