You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
ToView() equivalent in Data Annotations missing in docs #913
@carlosmunozrodriguez Data annotations support only a subset of EF Core modeling. For this case I believe you need to use the fluent API. However, I added a note to dotnet/efcore#10111 to consider adding support for attribute mapping in the future.
Just to add a note. I have successfully used [Table("TableName", Schema = "SchemaName")] to decorate a class that I use with DbQuery<T> to map a View. Although a [View] attribute probably makes more sense.
This was closed in favor of dotnet/efcore#10111 which was closed in favor of dotnet/efcore#10864 which was closed to track these in separate issues (so, in favor of this issue, among the others).
As a result, this is still missing.
One way this can be done is to allow null in [Table] annotation.
Activity
ajcvickers commentedon Aug 13, 2018
@carlosmunozrodriguez Data annotations support only a subset of EF Core modeling. For this case I believe you need to use the fluent API. However, I added a note to dotnet/efcore#10111 to consider adding support for attribute mapping in the future.
carlosmunozrodriguez commentedon Aug 13, 2018
Just to add a note. I have successfully used
[Table("TableName", Schema = "SchemaName")]to decorate a class that I use withDbQuery<T>to map a View. Although a[View]attribute probably makes more sense.MonstraG commentedon Aug 1, 2023
This was closed in favor of dotnet/efcore#10111 which was closed in favor of dotnet/efcore#10864 which was closed to track these in separate issues (so, in favor of this issue, among the others).
As a result, this is still missing.
One way this can be done is to allow
nullin [Table] annotation.ErikEJ commentedon Aug 1, 2023
Is it not [Keyless] ?
MonstraG commentedon Aug 1, 2023
It still creates a table in the migration, I added [Keyless] and
.ToView(null)to prevent that.