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
I have several classes that contain an array of linked items that should be stored in a separate table, using foreign keys to maintain a reference back to their parent. For example:
This setup builds the correct model and migrations, but fails at runtime if the array actually contains values. If I replace LinkedEntity[] with ICollection<LinkedEntity>, there are no errors, and the data is stored appopriately. However, the real MyEntity class is auto-generated and used by XmlSerializer which only supports collections that are arrays.
I would like to see arrays treated the same as any other collection type. They are already treated as such when building the model. Why are they treated any differently at runtime?
The text was updated successfully, but these errors were encountered:
@bcallaghan-et EF needs a collection type that can have items added to it. Arrays can't be used because they are always a fixed size and the ICollection.Add method always throws.
Implementation of #2919 would allow this, so this is likely a duplicate of that issue--we will discuss.
I have several classes that contain an array of linked items that should be stored in a separate table, using foreign keys to maintain a reference back to their parent. For example:
This setup builds the correct model and migrations, but fails at runtime if the array actually contains values. If I replace
LinkedEntity[]
withICollection<LinkedEntity>
, there are no errors, and the data is stored appopriately. However, the realMyEntity
class is auto-generated and used byXmlSerializer
which only supports collections that are arrays.I would like to see arrays treated the same as any other collection type. They are already treated as such when building the model. Why are they treated any differently at runtime?
The text was updated successfully, but these errors were encountered: