Entity Framework 6.1 SaveChanges() -> Could not load file or assembly 'System.ComponentModel.DataAnnotations'

2

Guys I'm out of ideas...

Info :

  • WPF aplication (C#, .net Framework 4.5)
  • EntityFramework 6.1
  • Recreated whole model (even merged from 3 models to 1)
  • Uninstalled/installed EntityFramework (console and nuget) few times :)

Everything works fine if I run it from VS, but when I run .exe (or ClickOnce) there is error... I have System.ComponentModel.DataAnnotations in my references, EF adds it on its own.¸I deleted/re added it on my own...still same.

I tried to set both copy localy to true and false, it even stops working in VS when i copy it localy.

All Error info :

Message:

Could not load file or assembly 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Either a required impersonation level was not provided, or the provided impersonation level is invalid. (Exception from HRESULT: 0x80070542)

Source:

EntityFramework

Trace:

   at System.Data.Entity.Internal.Validation.EntityValidatorBuilder.BuildTypeValidator[T](Type clrType, IEnumerable`1 edmProperties, IEnumerable`1 navigationProperties, Func`3 validatorFactoryFunc)
   at System.Data.Entity.Internal.Validation.EntityValidatorBuilder.BuildEntityValidator(InternalEntityEntry entityEntry)
   at System.Data.Entity.Internal.Validation.ValidationProvider.GetEntityValidator(InternalEntityEntry entityEntry)
   at System.Data.Entity.Internal.InternalEntityEntry.GetValidationResult(IDictionary`2 items)
   at System.Data.Entity.DbContext.ValidateEntity(DbEntityEntry entityEntry, IDictionary`2 items)
   at System.Data.Entity.DbContext.GetValidationErrors()
   at System.Data.Entity.Internal.InternalContext.SaveChanges()
   at System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
   at System.Data.Entity.DbContext.SaveChanges()
   my function call

If you need any more info please ask.

c#
.net
wpf
entity-framework
asked on Stack Overflow Apr 12, 2014 by lanicor • edited Apr 12, 2014 by har07

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0