none
Drag UserControl that uses Linq To Entities onto Windows Form, No Connection String named '' could be found in application config file

    Question

  • I have created a Visual Studio 2013 Solution with two projects: A Windows Forms project and a Class Library project. In the Class Library project I have added an entity framework, resulting in an .edmx file and an app.config file. I have copied the app.config file to the Windows Forms project and added a reference to EntityFramework.dll and a reference to the Class Library.

    When there is no code in the user control, I can drag the user control onto the main windows form with no error. However, if I use Linq to Entities in my user control and then try to drag it onto my form, I get an error. 

    Code in User Control that causes error:

    adminentities = new ClassLibrary1.AdminEntities();
    var res = from pay in adminentities.PayrollSchedules.Where(x=>x.FiscalYear == 2015) select pay;

    The error is:

    Failed to create component 'NavigationUserControl'...'No connection string named 'AdminEntities' could be found in the application config file.'

    There IS an app.config file in the windows form project with a connection string named 'AdminEntities'. I have also tried a few suggestions I found: 1) Changed * in the connection string to use the namespace of the class library and 2) replaced " with a single quote. Neither of these changes fixed the issue.

    How can I resolve this? Thank you.



    Thursday, February 19, 2015 11:13 PM

Answers

  • Hi RLuther,

    >> Failed to create component 'NavigationUserControl'...'No connection string named 'AdminEntities' could be found in the application config file.'

    Based on the error message, this issue would be related to the data platform, I suggest you post this issue to the ADO.NET Entity Framework and LINQ to Entities forum for dedicated support.

    The forum link:

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=adodotnetentityframework

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Sunday, February 22, 2015 8:14 AM