c# - Models / Entities vs complex types -
i have problem understanding complex data types vs entities in asp mvc , c#. started creating following type, not meant entity (db table):
public class period : iperiod { public datetime { get; set; } public datetime { get; set; } }
i added type model:
public class event { public int id { get; set; } public string title { get; set; } public period eventtime { get; set; } }
this worked fine. seemed understand period complex type, not entity. added columns eventtime_from , eventtime_to event table.
however, added complexity period type removing interface, moving class different namespace , adding methods class. suddenly, when trying rebuild database, interpreted entitytype, throwing exception missing primary key.
what system here? when classes seen complex types, , when seen entities?
it hard going on without knowing changes made can tell ef explicitly period
complex type either marking complextype
attribute or using fluent mapping:
modelbuilder.complextype<period>();
Comments
Post a Comment