Quantcast
Viewing all articles
Browse latest Browse all 8156

Why need key in Entity in Entity Framework

Hi There,

We are creating some entities in Entity Framework. It is not associate to any Database means we create blank edmx file and adding new Entity in the same. We create new entity with name AuditData which contains following fields.

 Scalar Property : Type

 FieldName       : string

CreateDate      : DateTime

CreatedBy       : Int

UpdatedDate     : DateTime

UpdatedBy       : Int

 

But when I am trying to save this entity, it Run custom tool automatically and give following error.

 Error 1 Running transformation: EntityType 'EntityModel.AuditData' has no key defined. Define the key for this EntityType. .\..\Model\EntityModel.edmx

After that I add new property by name ID and mark it as EntityKey. After that it generates class successfully, which I don't require in this entity. Can please how I can avoid this error without adding any key in entity.

 

Ankush


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>