0

I want to use the Entity Framework 7 in my ASP.NET Core 1 application to connect to a PostgreSQL database.

If I add EntityFramework.Commands (7.0.0-beta5) and EntityFramework7.Npgsql (3.1.0-rc1-3) to my project.json file:

{
  "webroot": "wwwroot",
  "version": "1.0.0-*",

  "dependencies": {

    "Microsoft.AspNet.Mvc": "6.0.0-beta5",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta5",
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta5",
    "Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta5",
    "Microsoft.AspNet.Authentication.Google": "1.0.0-beta5",
    "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta5",
    "Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta5",
    "Microsoft.AspNet.Diagnostics": "1.0.0-beta5",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta5",
    "Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta5",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta5",
    "Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta5",
    "Microsoft.Framework.Logging": "1.0.0-beta5",
    "Microsoft.Framework.Logging.Console": "1.0.0-beta5",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta5",

    "EntityFramework.Commands": "7.0.0-beta5",
    "EntityFramework7.Npgsql": "3.1.0-rc1-3"
  },

  "commands": {
    "web": "Microsoft.AspNet.Hosting --config hosting.ini",
    "ef": "EntityFramework.Commands"
  },

  "frameworks": {
    "dnx451": { },
    "dnxcore50": { }
  },

  "publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc"
  ],
  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ]
}

I get errors in my Startup.cs

using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Diagnostics;
using Microsoft.AspNet.Hosting;
using Microsoft.Framework.Configuration;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Logging;

namespace Suplim.Web.Platform
{
    public class Startup
    {
        public IConfiguration Configuration { get; set; }

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
        }

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.MinimumLevel = LogLevel.Information;
            loggerFactory.AddConsole();

            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseErrorPage(ErrorPageOptions.ShowAll);
            }
            else
            {
                app.UseErrorHandler("/Home/Error");
            }

            app.UseStaticFiles();


            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
    }
}

Then Visual Studio says that in my Startup.Configure() method it can not find the methods:

  • app.UseBrowserLink
  • app.UseErrorPage
  • app.UseErrorHandler
  • app.UseStaticFiles
  • app.UseMvc

It says

  • Core DNX 4.5.1 not available
  • Core DNX Core 5 available

But both packages are loaded and available in the Visual Studio references structure (DNX 4.5.1 and DNX Core 5).

If I remove the EntityFramework.Commands and EntityFramework7.Npgsql packages everything works fine.

Why does the Entity Framework affect my Startup class? Are the versions incompatible (beta5 and rc1-final)? If yes what can I do?

I do not understand the problem.

3 Answers 3

3

You are using an rc1 package for EF and beta5 for anything else. You can't mix package versions. Move everything to rc1 (beta5 is a thing of the past) and use the rc1 runtime (dnx) otherwise things will break.

Sign up to request clarification or add additional context in comments.

Comments

0

I have already tried to set the same version to all packages but some packages are still beta-* and others are rc1-final. These are the newest packages (I removed the EntityFramework7.Npgsql and other not needed packages for testing):

  "dependencies": {
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
    "Microsoft.Framework.Logging": "1.0.0-beta8",
    "Microsoft.Framework.Logging.Console": "1.0.0-beta8",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",

    "EntityFramework.Commands": "7.0.0-rc1-final"
  },

And my global.json is now:

{
  "projects": [ "src", "test" ],
  "sdk": {
    "version": "1.0.0-rc1-final",
    "runtime": "clr",
    "architecture": "x86"
  }
}

Now it can not find the EntityFramework.Commands and Microsoft.AspNet.Mvc packages (both with different version number than 1.0.0) in the DNX 4.5.1 reference. In the DNX Core 5 reference it finds nothing, all packages are unresolved.

It is like the old DLL hell ...

5 Comments

this is not the way of updating u'r question, move it to original post with Edit - Remark title.
Also, the logging dlls are in rc1-final. You may be pointing to the wrong nuget feed. I would work on getting everything on the same version first then worry about errors.
Have you checked your nuget feeds? Make sure you have this one I believe. myget.org/F/aspnetmaster
@RickJames I am going to try the aspnetmaster repo tomorrow, thank you. I hope it will solve some problems.
@maz258: Don't post updates or comments as answers. StackOverflow is not a form, its a Q/A site.
0
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7" 

needs to be changed to

"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final"

As the other responder says you are mixing and matching. You should have everything on the same version or don't use it.

3 Comments

Ok, but what is with the Mvc? It is version 6.0.0-rc1-final and is not resolved. Also EntityFramework.Commands and EntityFramework7.Npgsql are in different versions than 1.0.0-rc1-final. I am not able to use them in a 1.0.0-rc1-final? And why nothing is resolved in the DNX Core 5 references? Sorry but it is very confusing, it was much easier in classic ASP.NET MVC 5.
I know it is still beta but it is very confusing ;-)
I agree it can be confusing. Hence though why it is beta. Everything has changed with each version of beta. So namespaces have changed etc and that adds to the confusion. It is the price we pay for using cutting edge.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.