0

I am developing a Web API using VS Code and DNX. At the moment I am in the need of installing Entity Framework. When I am installing the package using dnu install EntityFramework there is no error. It adds the entry "EntityFramework": "7.0.0-beta4" in package.json file as well as updating project.lock.json.

But when I am compiling the application using dnu build I am getting the following error message and build fails:

IHostingEnvironment exists in both Microsoft.AspNet.Hosting.Abstractions, and Microsoft.AspNet.Hosting.Interfaces

My DNX version is 4.5.1

I have no idea about the issue! Someone please tell me how I can get this resolved.

Thanks in advance.

Update:

When I remove the entry "EntityFramework": "7.0.0-beta4" from project.json file, run dnu restore and then recompile using dnu build it is successful. My guess is there is already an EntityFramework installed by default (?) in my application. If it is so, when I add the namespace System.Data.Entity in my controller, it is not getting resolved.

The message I am getting is:

The type or namespace 'Data' does not exists in the namespace 'System' (are you missing an assembly reference?) [dnx451, dnx451, dnxcore50, dnxcore50]

Doesn't System.Data gets installed automatically?

UPDATE (project.json file)

{
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },
  "tooling": {
    "defaultNamespace": "apiservice"
  },
  "dependencies": {
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
    "System.Net.Http": "4.0.1-beta-23516",
    "Microsoft.Net.Http": "2.2.29",
    "EntityFramework": "7.0.0-beta4"
  },
  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel"
  },
  "frameworks": {
    "dnx451": {},
    "dnxcore50": {}
  },
  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ]
}
Subrata Sarkar
  • 2,975
  • 6
  • 45
  • 85

1 Answers1

0

You should probably remove the Interfaces and just use the Abstractions as this package was renamed.

See announcement: https://github.com/aspnet/Announcements/issues/14

Roberto Hernandez
  • 2,397
  • 1
  • 16
  • 18
  • Thanks! Removing those Interface parameters compiles the application. Now I see `System.Data namaespace` is available. But even with `EntityFramework` installed I am not getting `System.Data.Entity` namespace. Why is so? – Subrata Sarkar Dec 31 '15 at 05:18