locked
EF Code First approach Changing connection string RRS feed

  • Question

  • I trying to change ConnectionString(database connection) run time for clients made GUI for this

    I use [Microsoft example]

    https://docs.microsoft.com/en-us/dotnet/api/system.data.entityclient.entityconnection.connectionstring?redirectedfrom=MSDN&view=netframework-4.8#examples

    to change connection string It was *worked* on **Database First** approach

    now migrating to **Code First** seems this approach does not use 

        .csdl  .ssdl  .msl 

    metadata files [This] answer confirms

    https://stackoverflow.com/a/20374520/4944978

    when 

        metadata=res://*/dbBind.Model1.csdl|res://*/dbBind.Model1.ssdl|res://*/dbBind.Model1.msl;

    is in changed ConnectionString gives error **Unable to load the specified metadata resource**

    then cut it out gives this error 

        Some required information is missing from the connection string. The 'metadata' keyword is always required



    • Edited by baganaakh Thursday, April 9, 2020 8:37 AM
    Thursday, April 9, 2020 8:36 AM

All replies

  • Hello,

    It appears you were at one point working with .edmx and if I hear you have now move to code first. For Entity Framework 6 see the following. Or as in this example with the constructor overload takes a connection string.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Thursday, April 9, 2020 2:06 PM