mustang888
mustang888

Reputation: 205

Entity Framework - change display name of tables/entities

As the title suggests, I was wondering if it's possible to change the display name of my tables across all of my application.. currently my tables from my DB have complicated names and was wondering if I can change the display name so that it's more user-friendly.

Is there a class I can create that would do that for me?

I've looked at the following thread but not sure if this applies to my scenario.. I'm new to EF :)

Thanks!

Additional Info: I'm using the database first approach and currently have an EDMX setup.

Upvotes: 1

Views: 2155

Answers (2)

Paulo Correia
Paulo Correia

Reputation: 616

If you are using the Code-first approach, you should check the answer from Vitor M. Barbosa. If you are using Database First (has an EDMX), you can achieve that by changing the Name of the table/entity in your diagram. Internal EF will map that name to the table in the database.

Upvotes: 1

Vitor M. Barbosa
Vitor M. Barbosa

Reputation: 3646

If you're doing code-first, you'll just need some data annotations, e.g.:

[Table("TableName")]  
public class Table

[Column("BlogDescription", TypeName="ntext")]
public String Description {get;set;}

Upvotes: 0

Related Questions