none
L2E and database RRS feed

  • Question

  • Hi all,

    I'm trying L2E for the first time so I just created an entity model from an existing database. I called the edmx file 'DataModel'. However I have a few questions:

    1. My database has over a 100 tables and they are all used. Won't there be too much clutter in the edmx file?

    2. We have various clients and most of our clients have multiple databases (having the exact same schema of course). Clients usually select the database when logging in the application. I noticed that the connectionstring the app.config file is hardcoded to the database I selected when creating the entity model. How can I overcome this problem?

    3. I'm trying to add 'using DataModel' to my classes but it doesn't find it. Do I need other using statements before?

    Thanks,

    Ivan

    Monday, May 7, 2012 10:57 AM

Answers

  • Hi Cryo75,

    The connection string can be changed programmatically, please refer to this link. Example 16.2 introduces Programmatically modifying an EntityConnectionString.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us


    Wednesday, May 9, 2012 6:49 AM
    Moderator

All replies

  • Hi Cryo75,

    Welcome to MSDN Forum.

    1. You can split one large entity model into smaller ones to prevent that. More information, please refer here. This article introduces a couple of examples to demonstrate how to realize that. Furthermore, if you are interested in the performance impact about a large entity model, you can also refer here.

    2. You can write the connection string in the configuration file, ObjectContext has many constructors, you can pass the proper connection string to it.

    3. I'm not clear about this question, where did you write "using DataModel", and what's the purpose of it?

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, May 8, 2012 9:12 AM
    Moderator
  • Thanks for the answers. Forget about issue 3!!

    I also noticed that one constructor generated by the wizard uses a connection string :)

    Tuesday, May 8, 2012 9:18 AM
  • Hi Cryo75,

    The connection string can be changed programmatically, please refer to this link. Example 16.2 introduces Programmatically modifying an EntityConnectionString.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us


    Wednesday, May 9, 2012 6:49 AM
    Moderator