2

Using C#/MVC/Entity Framework with Visual Studio for Web 2013 Express.

For every model I create, <Model Name>.Context.cs always is just "ErrorGeneratingOutput".

This results in the following error:

Error   1   A namespace cannot directly contain members such as fields or methods   C:\[..]\Part Compare\Models\Parts.Context.cs    1   1   Part Compare

I also get these errors upon creating a model:

Error   2   Compiling transformation: Metadata file 'D:\Microsoft Visual Studio 12.0\Common7\Tools\..\IDE\EntityFramework.dll' could not be found   C:\[..]\Part Compare\Models\Parts.tt    1   1   Part Compare

Error   3   Compiling transformation: Metadata file 'D:\Microsoft Visual Studio 12.0\Common7\Tools\..\IDE\Microsoft.Data.Entity.Design.dll' could not be found  C:\[..]\Part Compare\Models\Parts.tt    1   1   Part Compare

I've tried reinstalling Entity Framework via Nuget, creating models from different sources, etc.

Nothing seems to fix it.

theg721
  • 21
  • 1
  • 3
  • possible duplicate of ["A namespace cannot directly contain members such as fields or methods" in Net.Reflector](http://stackoverflow.com/questions/21175781/a-namespace-cannot-directly-contain-members-such-as-fields-or-methods-in-net-r) – Gert Arnold Aug 30 '14 at 22:47
  • 1
    I disagree. Your link is for something totally different - game development in Unity (apparently) as opposed to an Entity Framework issue in VS. Additionally, the error/issue is different and the solution non-applicable. If you disagree please respond why, otherwise, any other ideas/possible duplicates are much appreciated as I'm still struggling with this issue. Thanks. – theg721 Aug 31 '14 at 02:07
  • The "duplicate" shows the kind of code that may cause this error. This may give a hint. We can't see your code, so for us it can be anything. – Gert Arnold Aug 31 '14 at 08:06
  • I don't have any code yet. This happens on any new project. I've looked into it more and apparently I need to downgrade Entity Framework to version 5 however Microsoft.AspNet.Identity.EntityFramework depends upon EF6. Any ideas? Sorry for my lack of details, I'm still somewhat new to Visual Studio for Web/ASP.Net/etc. – theg721 Aug 31 '14 at 13:19
  • The generated code must be screwed up somewhere. Try to find where. The compiler should show you the source of the error. – Gert Arnold Aug 31 '14 at 13:21
  • The compiling transformation errors lead to line 1, column 1 of .tt - I've put this on Pastebin [here](http://pastebin.com/J5Fwc6gG). Since it's telling me the Entity Framework .dll doesn't exist, I've tried reinstalling EF, but it errors because Microsoft.AspNet.Identity.EntityFramework depends upon it. I tried looking for the .dll, but I've searched D:\Microsoft Visual Studio 12.0\ and there is no EntityFramework.dll. I'm fairly certain that all my errors are resulting from the missing .dlls. – theg721 Aug 31 '14 at 13:46

0 Answers0