In Visual Studio 2010, how can I manually modify table mappings in ADO.NET? entity-framework visual-studio-2010


What I believe to be an obvious question has eluded me. I just constructed an entity model, and I want to manually change the names of the table and its fields. How can I alter or supplement the "mapping information" that I can see?

5/6/2010 9:23:49 PM

Accepted Answer

It seems that the solution is that you cannot do so without entering the XML. Although there is no direct GUI for altering the mappings, you may change the templates for creation using the Entity Framework Power Pack.

5/7/2010 9:18:57 PM

Popular Answer

I check through all of the files in the folder that contains the edmx file to locate a potential solution.

  1. My recommendation is to first install Notepad++, then right-click on the Edmx File in File Explorer, and thenEdit with Notepad++ then the contents of the xml file will display, or you may view the Edmx file directly using notepad.exe.
  2. On the top of the file, you'll see something similar:

    <EntityType Name="DataTableName">
        <PropertyRef Name="id" />
      <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" />
  3. I want to get rid of it.DataColumn4 I first open the Edmx File in VS and then immediately hit Delete on the keyboard after clicking on the column name in the VS UI. You can locate this in the Detail Mapping Window, the right side of the file.DataColumn4 although the land will be vacant, on the left side theDataColumn4 exist now.

  4. Next, save the file after removing the property in Step 2 of the edmx file.

    Remove--> <Property Name="DataColumn4" Type="nvarchar" MaxLength="255" />

  5. Open the edmx again after restarting Visual Studio, and you'll discoverDataColumn4 vanish, and when I attempt to connect to a database and modify data, everything goes well.

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow