It applies to the whole class. Remember that a partial class is just a way to split a class into multiple files. From official white papers :
At compile time, the attributes of the partial type definitions are combined.
So this is:
[SomeAttribute]
partial class PartialEntity
{
public string Title { get; set; }
}
[AnotherAttribute]
partial class PartialEntity
{
public string Name { get; set; }
}
It is equivalent to writing:
[SomeAttribute]
[AnotherAttribute]
partial class PartialEntity
{
public string Title { get; set; }
public string Name { get; set; }
}
If you want to add an incomplete class without the properties included in the model, you will need to add the attribute NotMappedto the individual elements:
partial class PartialEntity
{
public string Title { get; set; }
}
partial class PartialEntity
{
[NotMapped]
public string Name { get; set; }
}
source
share