0

From as far as I can tell all of the questions that relate to this have not solved my issue. I have an sql database hosted by Azure. Super simple, I want to connect it to my ASP.Net MVC app using Entity Framework.

Data Model has been added and edmx file is present, Connection string

  <connectionStrings><add name="MyDatabase" connectionString="...serverinfo"
providerName="System.Data.EntityClient" /></connectionStrings>

I go to my IdentityModels.cs and change the following

   public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    public ApplicationDbContext()
        : base("MyDatabase", throwIfV1Schema: false)
    {
    }

When i go to register a user in hopes that the users information will be added to my Azure database i get the following; "The entity type ApplicationUser is not part of the model for the current context."

I am kind of at my end on this. If someone can point me to documentation to build and applicaiton based upon a previously created database that I can follow or know what I am missing please let me know. Thank you

1 Answers1

0
Edit your Connection String and Modify your code as Follow - 

<connectionStrings>
<add name="MyDatabasedbEntitiesapplication"   providerName="System.Data.SqlClient" connectionString="database and username password;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" />
<add name="MyDatabasedbEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=yourdatasource,1433;initial catalog=yourdbname;user id=username;password=***;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>


Modify the code:

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    public ApplicationDbContext()
        : base("MyDatabase", throwIfV1Schema: false)
    {
    }

    public static ApplicationDbContext Create()
    {
        return new ApplicationDbContext();
    }
}

Modify AutomaticMigrationsEnabled = true; in Configuration class under Migrations folder.
Krunal Shah
  • 836
  • 8
  • 25
  • Why would it want the removal of Entities? The solutions works but I am still not sure why we need to remove "Entities" from the applicationDbContext. Thank you for the help. – AtLeastTheresToast Apr 06 '18 at 21:09