none
Table Mapping for Empty Entity Framework Designer model RRS feed

  • Question

  • I am using Entity Framework 6 and Visual Studio Professional with Update 5.

    I am trying to use an Empty Entity Framework Designer model to design my data first. I do not know how to do the table mappings. More specifically, I cannot get entities and properties to appear in the Mapping Details. I do not see a way to get the new table into the Mapping Details without generating the database.

    I can recreate the problem by adding an Empty Entity Framework Designer model to the project then adding an entity and adding a second property (the first is the Id that is supplied by default). When I validate the model I get ""Error 11007: Entity type 'Entity1' is not mapped." yet when I right-click the entity in the Model Browser and select Table Mapping, the "<Add a Table or View>" dropdown shows no tables.

    I have found How to: Map Entities to Database Tables. Step 2 says:

    In the Mapping Details window, click Add a Table or View.

    Yet the table is not in the list. I think I am doing everything it says to do.

    I have found entity framework - Cannot select table for discriminator (model-first) - Stack Overflow that seems to describe the problem. The suggested solution is to use Database generation power pack. Is there nothing in Visual Studio to do the mapping or do I need to use something else such as the power pack?

    I see that if I generate the database from the model but do not execute the DDL then it does not actually generate the database but it does add the table to the Mapping Details. If that is a necessary step then note that it seems to be undocumented in the relevant instructions.

    There is much to read in Model- First in the Entity Framework 4. I need to read it more but I do not see the answer there, it seems to say to create the model then generate the database. Again, if generating the database is a requirement for using the mapping details then that needs to be documented better.



    Sam Hobbs
    SimpleSamples.Info



    Wednesday, March 11, 2015 6:45 PM

Answers

  • Hello Sam,

    >>if generating the database is a requirement for using the mapping details then that needs to be documented better.

    The database is not necessary while the process for generating the DLL by clicking Generate Database from Model is needed. The mapping details is based on the .edmx file, you could open the .edmx with XML editor and you should see three sections:SSDL, CSDL and CSL and the table mapping detail is based on SSDL and CSDL sections.

    At first when you have created an empty, it only contains the CSDL and until running the Generate Database from Model command, it would generate the complete .edmx file and then you could use the table mapping details function.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, March 12, 2015 8:58 AM
    Moderator

All replies

  • Hello Sam,

    >>if generating the database is a requirement for using the mapping details then that needs to be documented better.

    The database is not necessary while the process for generating the DLL by clicking Generate Database from Model is needed. The mapping details is based on the .edmx file, you could open the .edmx with XML editor and you should see three sections:SSDL, CSDL and CSL and the table mapping detail is based on SSDL and CSDL sections.

    At first when you have created an empty, it only contains the CSDL and until running the Generate Database from Model command, it would generate the complete .edmx file and then you could use the table mapping details function.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, March 12, 2015 8:58 AM
    Moderator
  • Thank you, Fred. Somehow I did not get notification of your reply. I was going to delete this or change it to a discussion since I thought there was no response.

    I did finally manage to figure out how to use the properties to customize how the data will be stored. I think there is not much that has been written about the Model First approach and it is not obvious for beginners unfamiliar with the Entity Framework designer how to edit the properties.

    So the fundamental problem I was having is that I did not understand how to use the properties for fields (scalars).

    I like the idea of a model first approach but it is not as convenient as the Database First approach. In the Database First approach we have the Table Definition window with a grid showing the fields and the types in the grid. It is more convenient than the combination of Entity Designer and Properties windows. I think the way we specify the properties for fields using the Model First approach can be improved.



    Sam Hobbs
    SimpleSamples.Info

    Sunday, March 15, 2015 10:56 PM
  • Sam has the right of it. Designers are supposed to make things easier and currently, even if the instructions, such as they are, are followed to the letter, the designer just doesn't appear to work. It is a very frustrating experience for anyone new to model-first, it is no wonder that code-first is the more popular option.

    --Tim Long


    Tim Long

    Wednesday, June 10, 2015 12:48 PM
  • I hear that code-first will soon be the only option. So instead of fixing design-first they are abandoning it.


    Sam Hobbs
    SimpleSamples.Info

    Monday, April 3, 2017 11:56 AM
  • I hear that code-first will soon be the only option. So instead of fixing design-first they are abandoning it.


    Sam Hobbs
    SimpleSamples.Info

    Monday, April 3, 2017 12:10 PM