title: Entity Framwork: error 0194: Multiple versions were encountered
body: <p>I work from some years with Entity Framework on SQL Server, but this error is new for me.</p>
  
  <p>I created a library project (DLL) with an EDMX model. </p>
  
  <p>Then, I tested it from a little console application and it works.</p>
  
  <p>Finally, I tried to use it in the real project that needs this DLL and... it obviously doens't work!!</p>
  
  <p>The error I get is:</p>
  
  <blockquote>
    <p>System.Data.Entity.Core.MetadataException: Schema specified is not
    valid. Errors:  error 0194: All artifacts loaded into an
    ItemCollection must have the same version. Multiple versions were
    encountered.</p>
  </blockquote>
  
  <p>The complete stackTrace is:</p>
  
  <blockquote>
    <p>System.Data.Entity.Core.MetadataException: Schema specified is not valid. Errors: 
    error 0194: All artifacts loaded into an ItemCollection must have the same version. Multiple versions were encountered.
       in System.Data.Entity.Core.Metadata.Edm.EdmItemCollection.LoadItems(IEnumerable<code>1 xmlReaders, IEnumerable</code>1 sourceFilePaths, SchemaDataModelOption dataModelOption, DbProviderManifest providerManifest, ItemCollection itemCollection, Boolean throwOnError)
       in System.Data.Entity.Core.Metadata.Edm.EdmItemCollection.Init(IEnumerable<code>1 xmlReaders, IEnumerable</code>1 filePaths, Boolean throwOnError)
       in System.Data.Entity.Core.Metadata.Edm.EdmItemCollection..ctor(IEnumerable<code>1 xmlReaders, IEnumerable</code>1 filePaths, Boolean skipInitialization)
       in System.Data.Entity.Core.Metadata.Edm.MetadataCache.LoadEdmItemCollection(MetadataArtifactLoader loader)
       in System.Data.Entity.Core.Metadata.Edm.MetadataCache.&lt;>c__DisplayClass5.b__0(String k)
       in System.Collections.Concurrent.ConcurrentDictionary<code>2.GetOrAdd(TKey key, Func</code>2 valueFactory)
       in System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetMetadataWorkspace(DbConnectionOptions effectiveConnectionOptions)
       in System.Data.Entity.Core.EntityClient.EntityConnection.GetMetadataWorkspace()
       in System.Data.Entity.Core.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor, ObjectQueryExecutionPlanFactory objectQueryExecutionPlanFactory, Translator translator, ColumnMapFactory columnMapFactory)
       in System.Data.Entity.Internal.InternalConnection.CreateObjectContextFromConnectionModel()
       in System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
       in System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
       in System.Data.Entity.Internal.Linq.InternalSet<code>1.Initialize()
       in System.Data.Entity.Internal.Linq.InternalSet</code>1.get_InternalContext()
       in System.Data.Entity.Infrastructure.DbQuery<code>1.System.Linq.IQueryable.get_Provider()
       in System.Linq.Queryable.FirstOrDefault[TSource](IQueryable</code>1 source, Expression<code>1 predicate)
       in MailGunSender.MailManager.SendMail(String from, List</code>1 recipients, List<code>1 ccs, List</code>1 ccns, String subject, String text, String pathAttachment) in xxx:riga 261</p>
  </blockquote>
  
  <p>Of course, I have installed Entity Framework in the caller project (with Nuget), as I did for the tester console project. But here it gives me this error. Do you know why?</p>
  
  <p>My connection string is managed by this code:</p>
  
  <pre><code>public partial class Entities : DbContext
  {
      public Entities(string nameOrConnectionString)
          : base(nameOrConnectionString)
      {
  
      }
  
      public void Close()
      {
          this.Dispose();
      }
  
      public static string GetConnectionString(string server, string db, string user, string pwd)
      {
          string cn = "Server=" + server;
          cn += ";Database=" + db;
          cn += ";uid=" + user;
          cn += ";Pwd=" + pwd;
          var providerSB = new SqlConnectionStringBuilder(cn);
          var efConnection = new EntityConnectionStringBuilder();
          efConnection.Provider = "System.Data.SqlClient";
          efConnection.ProviderConnectionString = providerSB.ConnectionString;
          efConnection.Metadata = @"res://*";
          return efConnection.ToString();
      }
  }
  </code></pre>