Page 1 of 1

Entity Framework Core template and Data Annotations

Posted: Wed 05 Apr 2017 01:57
by RobertK
I noticed that DevArt class model code generator does not add either primary key "Key" or Foreign key "ForeignKey" or "Required" Data Annotations.

Shouldn't DevArt code generation template add the data annotation to help entity framework core determine which key is the primary keys and which key is the foreign keys?


Reference
https://msdn.microsoft.com/en-us/librar ... .113).aspx
https://docs.microsoft.com/en-us/ef/core/modeling/keys

Re: Entity Framework Core template and Data Annotations

Posted: Fri 07 Apr 2017 11:40
by Shalex
Be aware that the EF Core template generates fluent mapping for all classes (check ModelName.cs).

Anyway, for enabling Data Annotations please open your *.efml model, navigate to Tools > Entity Developer > Model Explorer, select the EF Core template, press F4 (Properties) and set its Validation Framework to Data Annotations. Save the model to regenerate the code (or press F7 in a standalone Entity Developer). Does this help?

Re: Entity Framework Core template and Data Annotations

Posted: Sat 08 Apr 2017 13:47
by RobertK
Shalex wrote:Be aware that the EF Core template generates fluent mapping for all classes (check ModelName.cs).

Anyway, for enabling Data Annotations please open your *.efml model, navigate to Tools > Entity Developer > Model Explorer, select the EF Core template, press F4 (Properties) and set its Validation Framework to Data Annotations. Save the model to regenerate the code (or press F7 in a standalone Entity Developer). Does this help?
Thanks Shalex, enabling Data Annotation solved the problem!