I've two projects:

  • Console application
  • Class Library

I would like the Class library to define the classes, create edmx files and to possess a partial connection string, like:

<add name="BlogEntities" connectionString="metadata=res://*/Blog.csdl|res://*/Blog.ssdl|res://*/Blog.msl;provider=System.Data.SqlClient;provider connection string='{0}'" providerName="System.Data.EntityClient" />

I would like my Class Library to define the csdl, ssdl and msl files. My Console application does not worry about the metadata, it'll only define the database, user and password.

How do i split the bond string in 2 such as this?

from the memory, should you produce the model inside a class lib, Versus can create an application.config within the lib project.

Simply merge this content of the file within the application.config from the console library.

within this scenario, you'll have a "design" config within the application.config file from the lib, along with a run time config within the application.config from the console application.

Produce a class inside your library (e.g. Connector) that enables you to definitely provide whatever connection values you'll need (database, user, password). Then make use of this class inside your console application and supply the required values nevertheless, you think fit.

I discovered will be able to title all organizations with similar title, e.g. Entities. My app.config will have to be around the Console Application, however i may use just one ConnectionString.

<add name="Entities" connectionString="metadata=res://*/;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLExpress;Initial Catalog=Test;Persist Security Info=True;User ID=test;Password=test;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

The metadata could be set to res://*/ and it'll work globally. From MSDN:

Model and mapping metadata utilized by the Entity Framework is loaded right into a MetadataWorkspace. This metadata is cached globally and it is open to other cases of ObjectContext in exactly the same application domain.

I'm also able to pressure that any plug-able module uses a ConnectionString creating the context constructor:

new Blogs.Data.Entities("name=Entities");