none
EF dll does not find connection string RRS feed

  • Question

  • Hi there,

    I am trying to use C# dll that uses entity framework. I am importing that DLL into a LabVIEW project and when run it throws an exception with a message 'No connection string named 'db_QualityEntitiesContext' could be found in the application config file'

    I have tried to look solutions on the internet but was able to figure out what needs to be done to get this working.

    Appreciate your help

    Jonas


    • Moved by CoolDadTx Wednesday, November 20, 2019 2:59 PM EF related
    Tuesday, November 19, 2019 11:12 AM

Answers

  • If the are using Entity Framework Core the connection setup may be in OnConfiguring in the DbContext class as shown in this code. The code is from a code sample I started on in memory testing but applies to non-memory testing too.

    The following shows setting the connection string in code and if done this way your best option is to ask the company who created the library for 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

    • Marked as answer by JonasLub Wednesday, November 27, 2019 10:44 AM
    Tuesday, November 19, 2019 1:09 PM

All replies

  • Hello,

    If using Entity Framework 6, not Entity Framework Core then there should be a connection string in the DLL, copy it to the project's app.config which is using the DLL.

    Here is an example.

    In this project app.config, a class project for EF there is a connection string. This project uses the other project for access to the EF classes and here is the app.config with the connection string from the first project.


    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

    Tuesday, November 19, 2019 11:26 AM
  • Hi Karen,

    I have tried but it hasnt worked for me yet, I am sure I was doing sosmething wrong but I will try to sort this out by looking at what has been said again.

    As I understand, the connection settings listed in the app config of the EF DLL must appear in the project app config file that uses the the DLL. However, LabVIEW language seems not to have app config file. Is it possible to get away of not using app config files such that the connection information is embedded into the the DLL?

    if that is not possible that means i wll need to recoded everything painfully :(((( old way using sqlclient objects.

    Thanks

    Jonas

    Tuesday, November 19, 2019 12:13 PM
  • If the are using Entity Framework Core the connection setup may be in OnConfiguring in the DbContext class as shown in this code. The code is from a code sample I started on in memory testing but applies to non-memory testing too.

    The following shows setting the connection string in code and if done this way your best option is to ask the company who created the library for 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

    • Marked as answer by JonasLub Wednesday, November 27, 2019 10:44 AM
    Tuesday, November 19, 2019 1:09 PM
  • LabVIEW language seems not to have app config file. I

    It the above is a project in Visual Stuido, then you can make an app.config for the project and copy the connectionstring from the  DLL project to the app.config in the other project.

    Tuesday, November 19, 2019 1:50 PM
  • it has helped me, thank you Karen for your help :)
    Wednesday, November 27, 2019 10:45 AM