For example, I use Entity Framework to create a database. I create a class and it has a List field. How will it look like in table? If it is int field, it is gonna be a column with numbers (same with strings, booleans...), I get it. But what about lists?
-
When you create this in Entity Framework and allow it to generate the database, what happens? – David Feb 28 '19 at 12:52
-
I'm not sure I understand the question. Can you elaborate please? – Thom A Feb 28 '19 at 12:52
-
@David nothing... I mean, it generates the database. – Sofia Bo Feb 28 '19 at 13:02
-
@SofiaBo: And when you look at the database, what do you find? Currently you're asking what your code outputs. So why not just look at the output? – David Feb 28 '19 at 13:04
-
1Please show an example and reword your question. This is too broad. – Gert Arnold Feb 28 '19 at 13:04
1 Answers
Based on what I can tell from your question you're wondering what happens if you're creating a database with Entity Framework from an code-first approach, from an entity which contains a list as a property. Entity Framework doesn't save lists as columns in your table, instead it creates a relationship between the two types of entities. If you have a class "Bob" which contains a List of type , then a relationship will be established. If the data type is primitive, you could either create a new entity that stores the primitive datatype or do some sort of string processing as explained by the answer in this question: EF can't store list string
EDIT: Read more about relationship databases here on Entity Framework tutorial: Configure one to many EF

- 74
- 8