Mike Stone
Mike Stone

Reputation: 319

ASP.Net Identity with WebForms to existing SQL database

I tried the ASP.Net identity and it works fine. I then tried to get it working with an existing SQL database using the pre-created scripts as provided here: SQL script for creating an ASP.NET Identity Database

I changed the default connection string to the one defined in web.config:

 public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    public ApplicationDbContext()
        : base("MyDatabaseEntities")
    {
    }
}

I foolishly assumed this was all I needed to change since the tables were created and I was pointing it to the SQL database. When I attempt to register a new user, the error message is: {"The entity type ApplicationUser is not part of the model for the current context."}

QUESTION: What am I missing to make this work? Is there a best practice for implementing Identity with existing SQL databases using Entity Framework? Thanks.

Upvotes: 2

Views: 7232

Answers (2)

Mike Stone
Mike Stone

Reputation: 319

We decided that since we would be creating a new database that we would just follow the code-first approach.

For those interested I found this Use ASP.NET Identity on existing DB-Model and it is VERY good. I tried following it but got stuck right at the end and didn't want to spend a lot of time on it since CF was decided.

Thanks for the help

Upvotes: 2

Sampath
Sampath

Reputation: 65870

You can use ASP.NET Identity Database for that.Which is a SQL Database project template for Visual Studio which can be used to create a custom ASP.NET Identity / Membership provider using Database First development approach.

Please check below mnetioned link for more info :

ASP.NET Identity Database

Upvotes: 2

Related Questions