0
When using a database I have tables and columns with names like:
- tb_usuario
- usu_id
- last name
- usu_data_nasc
- tb_product
- pro_id
- pro_name
- pro_desc_resumida
- pro_desc_completa
When using ADO.NET Entity Data Model -> EF Designer From Database, it creates the entities classes in my project with the same name as the tables, and the properties with the same name as the database columns. But I do know that in the code it’s not good practice, and I don’t even want to be named after properties like: pro_desc_completa. But how: descriptionComplete.
However, how do I do this? It is possible to map a property or class with a table and have different names using EF Designer From Database?
Or what would be the best approach?
I understood, but I’ll have to do the mapping like this in the modelBuilder for all my classes, and all my properties. It’s going to be very hard work. I know that in java, we were able to map through an Annotation, I thought in c# it would have something like...
– Erico Souza
another issue, is, my context, is automatically generated by ADO.net, and comes with the warning that the code can be changed if my model is updated. So it’s not safe to touch it. So I can create a class, inherit from my context to do this implementation of Onmodelcreating?
– Erico Souza
You can use Annotation as well: [Table("tb_usuario")] decorating its class and , [Column("usu_id")] its properties. I will add the answer.
– Aline