Change db table name in EF4 (entity framework 4)

后端 未结 6 2105
离开以前
离开以前 2020-12-01 18:53

Does anyone know how to change the mapped db table for an entity in EF4 (entity framework 4)?

Later edit: I think i\'ve found the place where the table names are def

6条回答
  •  温柔的废话
    2020-12-01 19:10

    Because I created my database first, I did the following:

    1. Backed up the *.edmx file.
    2. Changed my database table name.
    3. Did as you suggested by renaming the Entity Set Name in the properties.
    4. I then Updated the model based on my database by right-clicking the entity.
    5. I noticed that the *.edmx file was missing half the lines, so I overlayed the *.edmx file with my backup, opened it in notepad, and did a replace all of my old table name with my new table name.
    6. Rebuilt the MVC Application, tested, and it worked.

    Note: Whether all these steps above are needed I don't know, it's just what I tried and it worked for me.

提交回复
热议问题