How can I add coreIdentity to existing DB




I have problem with adding Microsoft.AspNetCore.Identity.EntityFrameworkCore to my project. I have created db already (code-first) and now i need to add some tables, that are necessary to create login and register system.


i've tried to do some tutorials how to do it, but i have always the same error. Probably i forgot about smth easy.


I have 2 controllers, Home and Account. Home is doing operations on products and products lists. Account have to let me register users and let them login.



```
 public class AccountController : Controller
    {
        private readonly UserManager<IdentityUser> userManager;
        private readonly SignInManager<IdentityUser> signInManager;

        public AccountController(UserManager<IdentityUser> userManager,
                                  SignInManager<IdentityUser> signInManager)
        {
            this.userManager = userManager;
            this.signInManager = signInManager;
        }
        [HttpGet]
        public IActionResult Register()
        {


            return View();

        }
        [HttpPost]
        public async Task<IActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new IdentityUser { UserName = model.Email, Email = model.Email };
                var result = await userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await signInManager.SignInAsync(user, isPersistent: false);
                    return RedirectToAction("Main_menu", "Home");
                }

                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError("", error.Description);
                }

            }

            return View();
        }
    }

```

and my Context(I'm creating there 3 table, but db have much more becouse of IdentityDbContext)



```
 public class ProductContext : IdentityDbContext
    {

        public Microsoft.EntityFrameworkCore.DbSet<Product> Products { get; set; }
        public Microsoft.EntityFrameworkCore.DbSet<List> Lists { get; set; }

        public Microsoft.EntityFrameworkCore.DbSet<ProductList> ProductLists { get; set; }
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);

                optionsBuilder.UseSqlite("Data Source=database.db");
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {

            base.OnModelCreating(modelBuilder);
            modelBuilder.Entity<ProductList>()
                .HasKey(pl => new { pl.ProductId, pl.ListId });

            modelBuilder.Entity<ProductList>()
                .HasOne(pl => pl.Product)
                .WithMany(p => p.ProductList)
                .HasForeignKey(pl => pl.ProductId)
                .OnDelete(DeleteBehavior.Cascade);

            modelBuilder.Entity<ProductList>()
                .HasOne(pl => pl.List)
                .WithMany(l => l.ProductList)
                .HasForeignKey(pl => pl.ListId)
                .OnDelete(DeleteBehavior.Cascade);
        }
    }

```

and my View:



```
@model RegisterViewModel
@{
    ViewData["Title"] = "Register";
}

<h1>Rejestracja</h1>

<div class="row">
    <div class="col-sm-12">
        <form method="post">
            <div asp-validation-summary="All" class="text-danger"></div>
            <div class="form-group">
                <label asp-for="Email"></label>
                <input asp-for="Email" class="form-control" />
                <span asp-validation-for="Email" class="text-danger"></span>
            </div>

            <div class="form-group">
                Haslo:
                <input asp-for="Password" class="form-control" />
                <span asp-validation-for="Password" class="text-danger"></span>
            </div>
            <div class="form-group">
                Powtorz Haslo:
                <input asp-for="ConfirmPassword" class="form-control" />
                <span asp-validation-for="ConfirmPassword" class="text-danger"></span>
            </div>
            <button type="submit" class="btn btn-primary">Zarejestruj</button>

        </form>
    </div>
</div>

```

And startup:



```
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
            var contentRoot = configuration.GetValue<string>(WebHostDefaults.ContentRootKey);
        }

        public IConfiguration Configuration { get; }


        public void ConfigureServices(IServiceCollection services)
        {


            services.AddIdentity<IdentityUser, IdentityRole>()
                    .AddEntityFrameworkStores<ProductContext>();
            services.Configure<CookiePolicyOptions>(options =>
            {

                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();

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



```

When i want to move to this view i have:


InvalidOperationException: Unable to resolve service for type 'PracaInz.Models.ProductContext' while attempting to activate 'Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore`9[Microsoft.AspNetCore.Identity.IdentityUser,Microsoft.AspNetCore.Identity.IdentityRole,PracaInz.Models.ProductContext,System.String,Microsoft.AspNetCore.Identity.IdentityUserClaim`1[System.String],Microsoft.AspNetCore.Identity.IdentityUserRole`1[System.String],Microsoft.AspNetCore.Identity.IdentityUserLogin`1[System.String],Microsoft.AspNetCore.Identity.IdentityUserToken`1[System.String],Microsoft.AspNetCore.Identity.IdentityRoleClaim`1[System.String]]'.


Is it possible to add Microsoft.AspNetCore.Identity.EntityFrameworkCore to code-first database?


In whole project i have more views and i can move between it. The error appears only when im trying to use Microsoft.AspNetCore.Identity.EntityFrameworkCore.
The error concerns Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore.
The tables are empty.


When i dont have HttpPost Register method, i can move to the view. The problem is when im adding HttpPost method.
need to add 



```
services.AddEntityFrameworkSqlite().AddDbContext<ApplicationDbContext>();

```

and delete



```
services.AddIdentity<IdentityUser, IdentityRole>()
                    .AddEntityFrameworkStores<ProductContext>();

```

in startup.
the error was about bad startup configuration.
Was sending too much things.


ApplicationDbContext:



```
 public class ApplicationDbContext : IdentityDbContext
    {
        public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
            : base(options)
        {
        }
        public Microsoft.EntityFrameworkCore.DbSet<Product> Products { get; set; }
        public Microsoft.EntityFrameworkCore.DbSet<List> Lists { get; set; }

        public Microsoft.EntityFrameworkCore.DbSet<ProductList> ProductLists { get; set; }


        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);

             optionsBuilder.UseSqlite("Data Source=assistant.db");

        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {

            base.OnModelCreating(modelBuilder);
            modelBuilder.Entity<ProductList>()
                .HasKey(pl => new { pl.ProductId, pl.ListId });

            modelBuilder.Entity<ProductList>()
                .HasOne(pl => pl.Product)
                .WithMany(p => p.ProductList)
                .HasForeignKey(pl => pl.ProductId)
                .OnDelete(DeleteBehavior.Cascade);

            modelBuilder.Entity<ProductList>()
                .HasOne(pl => pl.List)
                .WithMany(l => l.ProductList)
                .HasForeignKey(pl => pl.ListId)
                .OnDelete(DeleteBehavior.Cascade);
        }
    }

```
it's not in the core, but you can use an app: <https://apps.owncloud.com/content/show.php/registration?content=170608> Here is a link to assist you.


<https://technet.microsoft.com/en-us/library/ms178078(v=sql.105).aspx>


If you had done a web search with the question you entered here, you would have found multiple sites that give you the instructions The answer is yes, but keep reading...

Firstly, in version 11.0.0, you'll get an error if you try to import raw IDP metadata directly from ADFS.  Version 11.1.0 should be able to handle it, but as I write this version 11.1.0 hasn't yet been released, so if you're on version 11.0.0, you'll need to download the metadata file, open it in a text editor, and remove the nodes with the following names: ds:Signature, RoleDescriptor, SPSSODescriptor.  Once you've done that you should be able to import it into CompleteFTP.

Secondly, you need to set the secure hash algorithm (advanced settings tab) to SHA1.

Thirdly, you need to tell ADFS which attribute it should send to CompleteFTP as the user-name.  To do this you have to create a claim rule with an incoming claim type of your choice (e.g. Windows account name), an Outgoing claim type of 'Name ID', an Outgoing name ID format of 'Unspecified' and Pass through all claim values selected.

For more information, please refer to [this Oracle blog post](https://blogs.oracle.com/blogbypuneeth/steps-to-configure-saml-sso-with-adfs-as-idp-and-weblogic-server-as-sp), keeping in mind that the step for configuring WebLogic doesn't apply to CompleteFTP. You have some minor problems to remove. This first batch is useless paid-search listings to make money for **HP**:



R1 - HKCU\Software\Microsoft\Internet Explorer\Main,Search Bar = [http://srch-qus9.hpwis.com/](/posts/bad_link/25407?url=http%3A%2F%2Fsrch-qus9.hpwis.com%2F)  

R1 - HKCU\Software\Microsoft\Internet Explorer\Main,Search Page = [http://srch-qus9.hpwis.com/](/posts/bad_link/25407?url=http%3A%2F%2Fsrch-qus9.hpwis.com%2F)  

R1 - HKCU\Software\Microsoft\Internet Explorer\Main,Default\_Page\_URL = [http://qus9.hpwis.com/](/posts/bad_link/25407?url=http%3A%2F%2Fqus9.hpwis.com%2F)  

R1 - HKCU\Software\Microsoft\Internet Explorer\Main,Default\_Search\_URL = [http://srch-qus9.hpwis.com/](/posts/bad_link/25407?url=http%3A%2F%2Fsrch-qus9.hpwis.com%2F)  

R0 - HKLM\Software\Microsoft\Internet Explorer\Main,Start Page = [http://qus9.hpwis.com/](/posts/bad_link/25407?url=http%3A%2F%2Fqus9.hpwis.com%2F)  

R1 - HKLM\Software\Microsoft\Internet Explorer\Main,Search Bar = [http://srch-qus9.hpwis.com/](/posts/bad_link/25407?url=http%3A%2F%2Fsrch-qus9.hpwis.com%2F)  

R1 - HKLM\Software\Microsoft\Internet Explorer\Main,Search Page = [http://srch-qus9.hpwis.com/](/posts/bad_link/25407?url=http%3A%2F%2Fsrch-qus9.hpwis.com%2F)  

R1 - HKLM\Software\Microsoft\Internet Explorer\Main,Default\_Page\_URL = [http://qus9.hpwis.com/](/posts/bad_link/25407?url=http%3A%2F%2Fqus9.hpwis.com%2F)  

R1 - HKLM\Software\Microsoft\Internet Explorer\Main,Default\_Search\_URL = [http://srch-qus9.hpwis.com/](/posts/bad_link/25407?url=http%3A%2F%2Fsrch-qus9.hpwis.com%2F)



This is a problem BHO:



O2 - BHO: (no name) - {FDD3B846-8D59-4ffb-8758-209B6AD74ACC} - (no file)



That's all I see for now. Are you running **DSL**? Found it…Check out this link [Error 26630.](https://supportcenter.checkpoint.com/supportcenter/portal?eventSubmit_doGoviewsolutiondetails=&solutionid=sk106641)



Basically user does not have permissions to run the install. Magda, have you found what you need, yet?


I did this many years ago. It is simple… the 2nd time you do it!  

Exit points are simply “interrupts” that IBM supplies. You can attach programs to them, and the programs will automatically run at that point. For setting your AS/400 up to accept FTP logons, for example, the exit point is:  

QIBM\_QTMF\_SVR\_LOGON and the format you wil use is: TCPL0100.


A program inserted there can control WHO can log on, and when.  

To control WHAT they can do, you use another exit point, QIBM\_QTMF\_SERVER\_REQ and use format VLRQ0100.


My notes (from 1999) say I used the IBM TCP manual to get this info, specifically: TCP/IP manual SC41-5420-01 page I-14.


I do not know if it will allow me to post code here, it is long and complex due to the number of variables and some of them being in hex.


Write me (drow@waxie.com) if you would like me to email you my program code.


David Row  

WAXIE Sanitary Supply  

San Diego, CA





This is a link for [Add-ons for Firefox](https://addons.mozilla.org/en-US/firefox/). These are programs written by users or developers that the browser knows how and when to call. The developers of Firefox designed it to allow external programs to be hooked in by users of the browser.


IBM did something similar for a lot of the TCP/IP and other server functions. (And a lot of other things.) When you connect to the FTP server for example, the server checks to see if a program has been registered to process FTP logon requests. The registered program is an ‘exit program’.


Browser add-ons get an entry added to a file someplace within the browser directory structure. In your iSeries, the entry would be added to the Registration Facility. (Not always, but that’s the commonly recognized object for exit points and programs.) Use WRKREGINF to review your registration facility.


To create an exit program, you need to know the parameter list that will be passed to your program and the exit protocol. To find the parameter list, you should start looking at the documentation for the server the exit program will be associated with. The protocol, the meanings of the parms and what to with them, is also there.


A FTP exit program would be structured after documentation within the [File Transfer Protocol exit programs](http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/rzaiq/rzaiqreferenceexit.htm) topic of the Information Center for your release.


Once registered, a server logon exit program (for example) would be called just before the server decides whether or not to accept the logon. Your exit program directly influences that decision by returning an ‘accept or reject’ parameter. It chooses based on examination of the input parms.


The exit program may control who can and cannot logon, where they may logon from, what times of day logons are accepted, or it might accept all logons — its purpose can be simply to write all logons to a log file or to send a message when particular logons happen. Your exit program can do whatever it is programmed to do at that point in the logon process.


It doesn’t have to be a ‘security’ function. It’s whatever you want it to be.


For the FTP server, there are two general exit points. One is just before a logon is accepted. The other is just before each transaction in a session is processed. You can control individual transactions just as you can logons. (FTP client has its own exit points.)


Most other exit programs work on similar principles.


A few issues complicate things.


* An exit program needs enough authority to do whatever it needs to do; it can’t always rely on the authority of the session user.
* An exit program shouldn’t unduly delay transactions; there’s no way to know how often an exit program may be called, so you don’t want it slowing down every single transaction.
* Exit programs may be called by many instances of a server at the same time; it shouldn’t be locking things that are needed by a different instance.
* IBM changes the interfaces at times and the servers themselves can get PTFs; regular, on-going maintenance can be needed — keep the programs direct with little complication.
* There are other issues, but those are enough to consider.


Code a very simple exit program that accepts the parms and returns an ‘Accept’ indication. Don’t have it do anything except maybe send a message to a message queue. That lets you see how the registration facility works and how the parms work. It also gives you a program that you can register and deregister in the future to check whether or not the server is stilling calling your program correctly. (Problems can happen.)


Tom There is an MS DOS tool you can use to add a service. It is SC.EXE. I shall illustrate its use with an example.

Suppose, that I had installed two Coldfusion 11 instances named *testInstance1* and *myNewCFInstance*. Their installation directories are, respectively

C:\ColdFusion11\testInstance1\

C:\ColdFusion11\myNewCFInstance\

To add them as Windows services, you could proceed as follows.

Click on the Windows Start symbol.

When you type *cmd* in the search field, a link to the DOS command prompt should appear.

Right-click on the link and select to *Run as Administrator*. You should now get the DOS command prompt.

You can now run the DOS command, SC, to add a Windows service. You will have to do this for each and every instance you wish to add, one instance at a time.

**testInstance1**

Type the following after the prompt and press enter:

*sc create "ColdFusion 11 testInstance1" binPath= C:\ColdFusion11\testInstance1\bin\coldfusionsvc.exe start= auto DisplayName= "ColdFusion 11 testInstance1"*

Explanation:

* You must leave a single space after each equal (=) sign.
* "ColdFusion 11 testInstance1" is the name of the Windows service.
* The start type is Automatic.

![](/legacyfs/online/1191406_pastedImage_20.png)

You should get the result "SUCCESS".

To add the description, you have to run SC once again:

*sc description "ColdFusion 11 testInstance1" "My first ColdFusion 11 instance"*

Explanation:

* You must use the exact Windows service name. It is, in this case,  "ColdFusion 11 testInstance1".
* You may use any description you like. But I would advise you to use something like "ColdFusion 11 instance name\_of\_instance"

![](/legacyfs/online/1191405_pastedImage_16.png)

**myNewCFInstance**

For my second instance, the DOS commands I used to create the Windows service and to add the description were, respectively,

*sc create "ColdFusion 11 myNewCFInstance" binPath= C:\ColdFusion11\myNewCFInstance\bin\coldfusionsvc.exe start= auto DisplayName= "ColdFusion 11 myNewCFInstance"*

Followed by

*sc description "ColdFusion 11 myNewCFInstance" "ColdFusion 11 instance myNewCFInstance"*

Some references:

<https://coldfusionsolution.wordpress.com/2014/11/12/how-to-create-service-for-coldfusion/>

[http://stackoverflow.com/questions/29702700/sc-exe-how-to-set-up-the-description-for-the-windows-ser...](http://stackoverflow.com/questions/29702700/sc-exe-how-to-set-up-the-description-for-the-windows-service)

<https://forums.adobe.com/thread/1152396> 

Should you make a mistake, and wish to delete a service, then see

[How to Delete a Windows Service in Windows 7, 8, 10, Vista, or XP](https://www.howtogeek.com/howto/windows-vista/how-to-delete-a-windows-service-in-vista-or-xp/ "https://www.howtogeek.com/howto/windows-vista/how-to-delete-a-windows-service-in-vista-or-xp/") The clue is `Access denied for user 'homestead'@'localhost'`


Do you have a user called `homestead`? Have you attempted to grant them access to the database?


If you're unsure of the answers to either of those questions, I think you should re-read the documentation. I don't know if this actually solves your issue, but I had the same problem and tried pretty much every solution out there.


Eventually, after installing the correct packages to support VS2012, I also installed [Entity Framework 6 Tools for Visual Studio 2012 & 2013](http://www.microsoft.com/en-us/download/details.aspx?id=40762)


After doing so (and a restart of VS) the connection showed up in the Entity Data Model Wizard.


Hope it solves your issue as well. [image] andrei:

a quick fix is to comment the line in the "on message" tab for the function node that is troubled

when you add a module in "setup", the "import as" name is made available to the function tabs...

[image]

... so you dont need to declare it nor do you need to set/get it from co…