Asp.net 5: Bind attribute with Include - include parameter is not a valid argument of the name attribute

I am writing code from an article, and there are:

public IActionResult Create([Bind(Include="Imie,Nazwisko,Stanowisko,Wiek")] Pracownik pracownik)
{
    blablablab
}

I want to compile, but it shows an error.

 include is not a valid named attribute argument.

But on the Internet, I saw code similar to my code. Does someone explain to me what is going on? Of course I'm using asp.net 5.

+4
source share
1 answer

In MVC 6, a property Includeno longer has a setter. You need to pass a list of related properties using the constructor:

public BindAttribute(params string[] include)
{
    Include = include;
}

And in your case:

public IActionResult Create([Bind("Imie","Nazwisko","Wiek")] Pracownik pracownik)
+7
source

All Articles