C# Entity Framework Basics Extending Our Entity Data Model Defining and Using a One-to-Many Relationship

Andre Martins
Andre Martins
1,629 Points

error CS1520: on "public Courses()", Return Type needed but can´t figure out why...

I'm following the Comic Book example, my code follow the video guidelines but can´t figure out what´s wrong @ line 7: public Courses() { ... }. The video do not have a return type in the same public Series() method.

1 Answer

Steven Parker
Steven Parker
171,242 Points

You forgot to include your code in the question, but I'll guess that you're trying to create a default constructor for the class "Course" but naming it "Courses". This would cause the error you are seeing because the different name (with an "s") would be seen by the compiler as a normal method (which requires a return type) and not a constructor.

Constructors must have the same name as the class, so removing the "s" and renaming it "Course" will probably resolve the issue.

For future questions, or if this doesn't fix the issue, be sure to include your code with the question.