Im currently working on an ASP.Net web app that uses Mongo as its backend. I have seen others try this and have changed my connection string in my Web.config to point to my Mongo instance on Heroku. My connection string format is as follows:
mongodb://username:[email protected]:port/database
The controllers and models built after creating a new ASP.Net MVC project with individual accounts selected have not been edited. I am unable to create new accounts or login with accounts I create through Mongo. I also received the following error:
Format of the initialization string does not conform to specification starting at index 0.
My research showed that this is typically due to a malformed connection string. I have double and triple checked my Mongo connection string but it looks right. Am I missing something?
Any help is appreciated!
EDIT
I noticed that I had the providerName="System.Data.SqlClient" in the connection string. Removing this yields a different error:
The connection string 'DefaultConnection' in the application's configuration file does not contain the required providerName attribute.
If you're looking for MongoDB identity store adapters supporting netstandard2.0 or netcoreapp2.0, I've recently released a MongoDb UserStore and RoleStore adapter for Microsoft.AspNetCore.Identity 2.0.
It allows you to use MongoDb instead of SQL server with Microsoft.AspNetCore.Identity 2.0:
https://github.com/alexandre-spieser/AspNetCore.Identity.MongoDbCore
I have implemented the RoleStore and UserStore.
Fully covered by integration tests and unit tests from the modified Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test test suite.
Hope this helps.
Default Asp.Net identity storage provider is working with Entity Framework that is geared for working with relational databases. MongoDB is a document database and just changing connection string will not work. You need to use different storage provider that can work with MongoDB.
A quick search reveals that there are few storage providers that work with MongoDB:
I've not tried any of them personally, but first one seems to be quite popular on GitHub.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With