I can't seem to find the answer to what I think is an easy question. I have a Entity model I just created and I want to set the name of the table and the columns by hand. I can see the "mapping details," but how do I edit them or add to them?
It appears the answer is, you can't without going into the XML. You can use the Entity Framework Power Pack to customize the templates for generation, but there's no direct GUI for editing the mappings.
I open the folder where edmx file in, look into all files in it, and find a possible solution.
Edit with Notepad++then the xml file content will show, or you can directly open the Edmx file by notepad.exe
You'll see something like this on the top part of the file:
<EntityType Name="DataTableName"> <Key> <PropertyRef Name="id" /> </Key> <Property Name="DataColumn1" Type="bigint" Nullable="false" /> <Property Name="DataColumn2" Type="datetime" Nullable="false" /> <Property Name="DataColumn3" Type="nvarchar" MaxLength="255" /> <Property Name="DataColumn4" Type="nvarchar" MaxLength="255" /> </EntityType>
What I want to do is remove
DataColumn4, I first open the Edmx File in VS and directly click on the column name in the VS UI and press Delete on the keyboard, and you'll find that in the Mapping Detail Window, the right side of
DataColumn4 property will be empty, but in the left side the
DataColumn4 still exist.
Then, Open the edmx file using Step 1, remove the property in the Step 2 and save the file.
Remove--> <Property Name="DataColumn4" Type="nvarchar" MaxLength="255" />
Restart visual studio, and open the edmx again you'll find
DataColumn4 disappear, and I try connect to DB and manipulate Data, works fine.