Build failed while working with Internet Template

Mar 28, 2013 at 6:35 AM
Hi ,

I faced a problem when Creating an solution using the Internet template. When building the application I see the error:
            “Metadata file 'E:\Elma_Folder\ACMF\Model\bin\Debug\Model.dll' could not be found  ACMF”

          “The type 'System.Data.Objects.ObjectContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.                E:\Elma_Folder\ACMF\Model\MyDbContext.cs               11           16           Model”

But when Creating an solution and Selecting the Empty template I do not see any error rather the solution runs successfully.

I install the NakedObjects.Mvc-FreshInstall.

Please help me by giving the solution.




Thanks,
Elma
Coordinator
Mar 28, 2013 at 9:01 AM
MyDbContext.cs is not a file created by the Nakedobjects.MVC.FreshInstall package.

If you create a completely new project from the MVC4 internet template and add the Nakedobjects.MVC.FreshInstall package and then immediately compile it without making any changes does it compile successfully ? If not you should make sure that your machine is fully up to date with the latest .net and VS2010/vs2012 code.

If you have created another project within the solution that has a DbContext in it you should add the EntityFramework nuget package to it.
Mar 31, 2013 at 7:01 AM
Thank you Scascarini for your reply.

I found that everything is ok with the project. My machine is fully up to date with the latest .net and VS2010 code.My problem is solved.
I found that when I wrote the code to MyDbContext.cs like this :
public class MyDbContext : DbContext
{
    public MyDbContext(string name) : base(name) { }
    public MyDbContext() { }
}
the error shows
“The type 'System.Data.Objects.ObjectContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. E:\Elma_Folder\ACMF\Model\MyDbContext.cs "

But when I wrote the code to MyDbContext.cs like this :
public class MyDbContext : DbContext
{
    public MyDbContext(string name) : base() { }
    public MyDbContext() { }
}
The project builds successfully.



Thanks,
Elma