Using the Object Model in a Class Library

I have a design solution consisting of two class libraries and a windows application. The two libraries are divided into Custom_Classes and Custom_Controls.

To me my Custom_Classes library I have an entity model referenced by the my Custom_Controls library to access specific data members. The connections work fine and when I add the control to my Windows Form it has no problem. But when I want to add a custom control inside another by dragging it from the toolbar, the following message appears.

Failed to create component 'u_Settings'. An error message appears: "No line named" MyEntitiesCon "was found in the application configuration file.

I made sure the connection string is in the app.config file and even tried adding it to the project settings file. Here is my connection string copied from the Custom_Classes project to the Custom_Controls project

<connectionStrings>
    <add name="MyEntitiesCon" connectionString="metadata=res://*/Enity_Framework.SP_Model.csdl|res://*/Enity_Framework.SP_Model.ssdl|res://*/Enity_Framework.SP_Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=XXX\XXX;initial catalog=XXX;integrated security=True;connect timeout=30;connectretrycount=2;MultipleActiveResultSets=True;App=EntityFramework&quot;"      providerName="System.Data.EntityClient" />
</connectionStrings>

      

I have tried a bunch of solutions but no success

+3


source to share


3 answers


First, it looks like bad design holding back principles SOLID

. You must depend on the abstract DataSource interface. The data source implementation should be decoupled from the control.

MSDN also has a good directive:



http://msdn.microsoft.com/en-us/library/ms171926.aspx

PS. Open the EF designer and try updating the model. Save your connection string and copy it to the project where you create your controls.

+1


source


Have you tried adding a connection string to app.config to your Windows Application project?



+1


source


If a connection string is required to initialize the designer, you need to put the connection string in every new project configuration that uses your control library. By the way, if you remove the connection string from the designer initialization, you will need to put it in the destination config file.

0


source







All Articles