Change Entity framework database schema at runtime

前端 未结 8 3261
花落未央
花落未央 2021-02-20 13:02

In most asp.net applications you can change the database store by modifing the connectionstring at runtime. i.e I can change from using a test database to a production database

8条回答
  •  轮回少年
    2021-02-20 13:27

    The connection string for EF is in the config file. There is no need to change the SSDL file.

    EDIT

    Do you have the prod and test schema in the same database?

    If Yes you can fix it by using a seperate database for prod and test. Using the same schema name in both databases.

    If No you can fix it by Using the same schema name in both databases.

    If you will absolutly have different schema names, create two EF models, one for test and one for prod, then select which on to use in code based on a value in your config file.

提交回复
热议问题