Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To use the "default convention based mapping" the following 2 approaches will work:</p> <p>1) The collision is caused by the connection string using a wild card:</p> <pre><code> metadata=res://*/Repositories.EntityFramework.Model.csdl|res://*/Repositories.EntityFramework.Model.ssdl|res://*/Repositories.EntityFramework.Model.msl; </code></pre> <p>Since * does not work your project you can define multiple connection strings to hard code the assembly containing the edmx.</p> <p>2) create a helper</p> <pre><code> public static EntityConnection GetEfConnectionString(this string sqlConnectionString) { var cs = string.Format(@"metadata=res://{0}/Repositories.EntityFramework.Model.csdl|res://{0}/Repositories.EntityFramework.Model.ssdl|res://{0}/Repositories.EntityFramework.Model.msl;provider=System.Data.SqlClient;provider connection string=""" + sqlConnectionString + @"""", Assembly.GetCallingAssembly().FullName ); return new EntityConnection(cs); } </code></pre> <p>Update 2017:</p> <pre><code> public static string GetEfConnectionString(this string sqlConnectionString, Type type) { string cs = string.Format( @"metadata=res://{0}/Models.Model.csdl|res://{0}/Models.Model.ssdl|res://{0}/Models.Model.msl;provider=System.Data.SqlClient;provider connection string=""" + sqlConnectionString + @"""", type.Assembly.FullName ); return cs; } // usage: don't "new" EntityConnection. See 2012 comment. string connString = ConfigurationManager.ConnectionStrings["sqlConnection"].ConnectionString.GetEfConnectionString(); using(var entities = new XyzEntities(connString)) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload