c# - Entity Framework code-first, error: "EntityType 'OfferSequence' has no key defined" -
i using entity framework code-first. trying create new entity called offersequence, table automatically created in database.
the problem when try update database new entity, following error
one or more validation errors detected during model generation:
erp.enterprisedataaccesslayer.enterprisedata.offersequence: : entitytype 'offersequence' has no key defined. define key entitytype. offersequences: entitytype: entityset 'offersequences' based on type 'offersequence' has no keys defined.
however, can see below, key clearily defined on property sequencestart
public class offersequence : ientity<offersequence> { public offersequence(uint sequencestart, uint incrementalcounter, uint annualincrementalcounter) { validate.ensureistrue(incrementalcounter >= sequencestart && annualincrementalcounter >= sequencestart, "counters can not lower sequence start"); sequencestart = sequencestart; incrementalcounter = incrementalcounter; annualincrementalcounter = annualincrementalcounter; lastupdatedate = datetime.utcnow; } [key] public uint sequencestart { get; private set; } public uint incrementalcounter { get; private set; } public uint annualincrementalcounter { get; private set; } public datetime lastupdatedate { get; private set; } public offersequence clone() { offersequence copy = new offersequence(sequencestart, incrementalcounter, annualincrementalcounter); return copy; } object icloneable.clone() { return clone(); } public void modify(offersequence obj) { annualincrementalcounter = obj.annualincrementalcounter; incrementalcounter = obj.incrementalcounter; lastupdatedate = datetime.utcnow; } }
it appears cannot use unsigned int key in entity framework: don't have official says this, answer on this question suggests it, this one.
edit: here official word ef team regarding this. here's said:
ef team triage: unsigned integers not supported efs internal model uses store metadata. should consider supporting them, or having way deal types aren't explicitly supported.
the error message improved here , symptom of our rule code first ignores properties of unsupported types. detect situation , provide better message.
given in ef6 release aren't going change now. moving future consider upcoming releases.
Comments
Post a Comment