Entity Framework Duplicate type name within an assembly (6.1.0)

前端 未结 10 1670
臣服心动
臣服心动 2020-12-29 01:41

I am not sure what is going on but I keep getting the following exception when doing a query. \"Duplicate type name within an assembly.\" I have not been able to find a solu

相关标签:
10条回答
  • 2020-12-29 02:22

    Had same issue that has taken hours yesterday to get rid of. Using EF 6.1.0, error on executing linq to entities query similar as above. My solution was to stop IIS Express, clean solution , uninstall EF from all projects in solution, close VS2012, delete all packages folders/files within solution, then restart VS2012, add EF 6.1.0 where needed, compile, error disappeared.

    0 讨论(0)
  • 2020-12-29 02:24

    With EF 6.1, I run into the same problem.

    In my case, my model has a self-reference table. So I found it might be caused by the following two reasons.

    1. //Database.SetInitializer(null) Just comment out the following line in DBContext constructor.
    2. keep foreign key and its corresponding navigation property consistent, or just keep the navigation property null
    0 讨论(0)
  • 2020-12-29 02:25

    Faced the same in my WCF webservice recently. Just clean your solution and rebuild it. This should fix the issue.

    0 讨论(0)
  • 2020-12-29 02:28

    None of the above seem to work for me however in the link specified earlier i did fin this, which worked for me. This was submitted by 'bunomonteiro'

    To Fix "Duplicate type name within an assembly"

    I had similar issue. I checked all my models/classes and I have not used duplicate names for types. I deleted the assemblies and regenerated the the model and context object from the database and still had the same issue.

    A trace yielded in Visual Studio "Children could not be evaluated". The SOLUTION is to add .ToList(); or ToArray(); or ToDictionary() etc, to your query. etc.

    eg. var query = context.TableName.Where(x => x.name =="CodeRealm").ToList();

    PingBack - http://entityframework.codeplex.com/workitem/1898

    bunomonteiro wrote Jul 18 at 3:37 AM

    0 讨论(0)
提交回复
热议问题