简体   繁体   中英

Change Entity Framework generated model classes

I am currently confusing myself or doing something wrong, could someone please help me to better understand this?

I am creating an application using ASP.Net MVC 5 and using Entity Framework, so what I have done I created the database tables and updated the Entity Framework from the database, so it creates a nice diagram for me and so, also it creates Model classes for me, which is great. However right at the top of the Model class I get the following comment: 在此处输入图片说明

and I have some get and set methods that have been generated by the database, however for the following attributes I want to add [Required] at the top but it always get overwritten, any suggestions?

在此处输入图片说明

I should have really looked at this first http://www.codeproject.com/Articles/148486/Adding-Metadata-to-Entities-in-The-Data-Model

It suggests that I create another model class with metadata in it, which is okay, not massive overwork, so thats cool

Many thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM