ASP.Net Identity with WebForms to existing SQL database

asp.net asp.net-identity c# entity-framework webforms

Question

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.

1
2
2/10/2014 4:42:57 PM

Accepted Answer

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

2
2/13/2014 2:48:28 PM

Popular Answer

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



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow