entity framework - class that represents an item with attributes where attributes are in a collection of attribute objects, using code first migrations -


I am trying to project a code first Entity Framework which contains two classes / tables. The second category / table represents the properties of this widget. That is, right threaded, left, threaded, small, bigger etc.

Each widget can have 1 or more attributes and each attribute can be related to multiple widgets.

How should I represent it in the empty code?

class widget {public entry ID (get; set;} public string name {get; set;} public iconging & lt; feature & gt; properties {find; set;}} class attribute {Public Ent ID (Get; Set;} Public String Name {get} Set;}}

The above classes give me several tables and two copies of the same feature in DB

Eventually I am trying to use the attribute table as a wide variety of extensions.

Because you do not have a navigation property on the attribute unit, the Anti Framework Convention will not determine that many To specify multiple relationships, you need to add the mapping code to the context.

  Safe Override Zero OnModelCreating (DbModelbuilder Modalbuilder) {modelBuilder.Entity  () .HasMany W = & gt; Double U.Features.) Many ();}  

The .ap () code in the example that is linked to you is only necessary if you want to specify the column or table name if you want to If you leave the code, then the unit framework will provide the name.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -