2013-11-15 3 views
0

Я попытался создать проект, реализующий структуру сущностей MySQL. Я добавил пакеты EntityFramework, MySql.Data и MySQL.Data.Entities NuGet. У меня также установлен mysql-connector-net-6.7.4. Я попытался удалить и удалить все эти вещи, но я все еще получаю ошибку ниже. Я добавил его в качестве сервера в проекте и смог попасть в db и вытащить тестовую таблицу. Я использовал соединение MySQL и смог подключиться к db через визуальную студию. Однако я продолжаю получать эту ошибку.Сущность фреймворка сущности MySQL при попытке добавить

Он не работает на последней строке кода ниже .

sql123456Entities context = new sql123456Entities(); 
test_table cookie = new test_table 
{ 
    this_is_cool = "Yes it is", 
    this_is_cooler = 32, 
    but_is_it_the_fonz = "Yeah!" 
}; 

context.test_table.Add(cookie); 

Сообщение об исключении (внутреннее исключение является нулевым)

{"Could not load file or assembly 'MySql.Data, Version=6.6.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"MySql.Data, Version=6.6.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"} 

Трассировка стека:

at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) 
    at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) 
    at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) 
    at System.Type.GetType(String typeName) 
    at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow) 
    at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) 
    at System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver.GetService(Type type, Object key, Func`3 handleFailedLookup) 
    at System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver.GetService(Type type, Object key) 
    at System.Data.Entity.Infrastructure.DependencyResolution.CachingDependencyResolver.<>c__DisplayClass1.<GetService>b__0(Tuple`2 k) 
    at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) 
    at System.Data.Entity.Infrastructure.DependencyResolution.CachingDependencyResolver.GetService(Type type, Object key) 
    at System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.<>c__DisplayClass3.<GetService>b__0(IDbDependencyResolver r) 
    at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext() 
    at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate) 
    at System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.GetService(Type type, Object key) 
    at System.Data.Entity.Infrastructure.DependencyResolution.RootDependencyResolver.GetService(Type type, Object key) 
    at System.Data.Entity.Core.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) 
    at System.Data.Entity.Core.EntityClient.EntityConnection..ctor(String connectionString) 
    at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection) 
    at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config) 
    at System.Data.Entity.Internal.LazyInternalConnection.Initialize() 
    at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel() 
    at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() 
    at System.Data.Entity.Internal.InternalContext.Initialize() 
    at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) 
    at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() 
    at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() 
    at System.Data.Entity.Internal.Linq.InternalSet`1.ActOnSet(Action action, EntityState newState, Object entity, String methodName) 
    at System.Data.Entity.Internal.Linq.InternalSet`1.Add(Object entity) 
    at System.Data.Entity.DbSet`1.Add(TEntity entity) 
    at ConsoleApplication2.Program.Main(String[] args) in c:\Users\recursor\Documents\Visual Studio 2012\Projects\CS3280\Final Project\IR\ConsoleApplication2\Program.cs:line 24 
    at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) 
    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
    at System.Threading.ThreadHelper.ThreadStart() 
+0

Какая версия этой сборки у вас есть, если таковая имеется? – ChrisBint

+0

У меня есть 6.7.4.0 во всех сборках, а также на каком коннекторе исполняется и указывается. Я не знаю, почему он просит эту конкретную версию. – Recursor

+0

db - это MySQL 5.5.34, поэтому более высокая версия должна работать для него (она запрашивает версию 6.5.5). Я просто не понимаю, почему он запрашивает эту версию и почему тот, который я предоставил, не работает. Я также не знаю, как дать ему тот, который он хочет, потому что я получил это от самого последнего пакета NuGet. – Recursor

ответ

0

Похоже, что были допущены ошибки в app.config. Во время выполнения были зависимые сборки с привязанными перепрямыми, которые были неправильными. Я должен был запускать EF5, потому что это последняя версия EF, поддерживаемая MySQL. Поэтому мне пришлось изменить привязку EF к этому:

<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" /> 
Смежные вопросы