Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IServiceCollection does not contain a definition for AddNpgsql #41

Closed
chrisjmccrum opened this issue May 31, 2016 · 2 comments
Closed

Comments

@chrisjmccrum
Copy link

I'm trying to use PostgreSQL for the first time and having a little trouble getting it to build without errors. To be sure I don't have conflicting packages, I made sure to update my project.json to RC2-*. Here's the final error that I can't seem to fix.

ERROR

Startup.cs(22,18): error CS1061: 'IServiceCollection' does not contain a definition for 'AddNpgsql' and no extension method 'AddNpgsql' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)

PARTIAL PROJECT.JSON

  "dependencies": {
    "AspNet.Security.OAuth.Introspection": "1.0.0-alpha1-final",
    "AspNet.Security.OAuth.Validation": "1.0.0-alpha1-final",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Mvc.Formatters.Json": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Mvc.Cors": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",

    "Microsoft.Extensions.Configuration.CommandLine": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",

    "Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.Commands": "1.0.0-rc2-*",
    "Microsoft.EntityFrameworkCore.Relational": "1.0.0-rc2-final",
    "Npgsql.EntityFrameworkCore.PostgreSQL": "1.0.0-*",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-rc2-final",

    "OpenIddict.Core": "1.0.0-*",
    "OpenIddict.EF": "1.0.0-*"
  },


  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0-rc2-3002702"
        }
      },

      "imports": [
        "dnxcore50",
        "portable-net451+win8"
      ]
    }
  }

PARTIAL STARTUP.CS

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

            services.AddEntityFramework()
                .AddNpgsql()
                .AddDbContext<DeadboltContext>(options =>
                    options.UseNpgsql("Host=localhost;Username=dev;Password=dev;Database=tesdb"));

            services.AddIdentity<tbl_ApplicationUser, tbl_ApplicationRole>()
                .AddEntityFrameworkStores<DeadboltContext>()
                .AddUserStore<CustomStore>()
                .AddDefaultTokenProviders()
                .AddOpenIddictCore<tbl_Application>
                    (conf => conf.UseEntityFramework());

            services.AddAuthorization(options => {
                options.AddPolicy("Default", builder => {
                    builder.RequireAuthenticatedUser();
                    builder.RequireActiveUser();
                });

                options.DefaultPolicy = options.GetPolicy("Default");
            });

            services.AddTransient<IEmailSender, AuthMessageSender>();
            services.AddTransient<IDatabaseInitializer, DatabaseInitializer>();
            services.AddTransient<IUtilityService, UtilityService>();
            services.AddScoped<ICommonRepository, CommonRepository>();
        }
@roji
Copy link
Member

roji commented Jun 1, 2016

In RC2 it's called AddEntityFrameworkNpgsql() and things have changed a little, read http://ef.readthedocs.io/en/latest/internals/services.html.

@roji roji closed this as completed Jun 1, 2016
@roji roji added the invalid label Jun 1, 2016
@cyraid
Copy link

cyraid commented May 16, 2024

What is it called now? Seems to be missing, and it's what the docs say. (If it's the same for IHealthChecksBuilder)

Edit: It's all good, I found out. I needed to add the Package "AspNetCore.HealthChecks.NpgSql"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants