Entity Framework Core template and Data Annotations

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
RobertK
Posts: 111
Joined: Thu 02 Mar 2017 05:44

Entity Framework Core template and Data Annotations

Post by RobertK » Wed 05 Apr 2017 01:57

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

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Entity Framework Core template and Data Annotations

Post by Shalex » Fri 07 Apr 2017 11:40

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?

RobertK
Posts: 111
Joined: Thu 02 Mar 2017 05:44

Re: Entity Framework Core template and Data Annotations

Post by RobertK » Sat 08 Apr 2017 13:47

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!

Post Reply