Comments (3)
  1. Anon says:

    Hi Alex,

    A related issue I’m having is changing the database at runtime.

    I think the root cause is the in the SSDL entitysets are being created with the Schema attribute


    <EntitySet Name="task" EntityType="hardModel.Store.task" store:Type="Tables" Schema="harder" />

    The result is that the database name is appearing the the final slq being executed, the database name being the design time database.

    Is there a workaround to prevent this from happening? I do not mind being limits to just one database.

  2. Alex D James says:

    @Anon (?)

    the Schema is not the database name, it is the schema, usually it is something like ‘dbo’.

    Both your production and development databases can have the same schema.


  3. Ann says:

    Clarifying my question..

    The production and test are on the same database system one is called  hardtest and the other hardprod. i.e  databases or schemas in the same database system/machine

    My question was in regard to designing using hardtest but then at runtime changing to use hardprod. Assuming the both hardtest and hardprod are the same structure I should be able to do this without issue.

    The issue issue I’m having is the the SQL EF is producing contains the database/schema name of the design time database. ie the sql looks like "Select * from  hardtest.task" instead of  "Select * from hardprod.task"

    The reason I think this is happening is that EF is storing the schema name in the SSDL EntitySet as stated above.

    If I manual edit the SSDL by deleting the Schema attribute in all the EntitySets them I get generic SQL that works ie SQL without any Schema defined "Select * from task"

    The problem with doing this is that when I try to update the EF model again it adds back all the EF entities (because I remove the Schema attribute from the SSDL it thinks everything is new and adds it to the model for a 2nd time)

    The solution you proposed in your blog post is about changing the SSDL and other files if the database design is different. But what is they are the same and I just want the generic SQL to not include the schemas.

    One thing is note is that changing the connection string does make EF hit the correct database/schema.. but the SQL being executed at this time contains the design time database name or schema.

Comments are closed.

Skip to main content