Ushan Kavinda
Ushan Kavinda

Reputation: 98

Rename entity of exisisitng project c# database first

I have ongoing windows application that developed by using entity framework database first approach. Suddenly i changed table names of all the tables in the data base, which means i added table prefix for every table. (ex: abc table to A_abc).

now i want to change the entity name also. but i can't change because the class name is using in the code. if i rename the entity class i have to rename also the coding according to new class name.

i need solution for this.please help!

Upvotes: 0

Views: 374

Answers (1)

Balaji
Balaji

Reputation: 127

Aren't you not mapping the entity and the table name somewhere?

In Code First Approach we can do this:

modelBuilder.Entity<Abc>().ToTable("t_Abc"); 

a. Is it not possible to override "OnModelCreating" in Database First, and map the entity and table as mentioned in the above code.

b. In Database First Approach, I haven't tried this; Let me know if this helps you.

Renaming Entity in DF

Upvotes: 1

Related Questions