I have a problem. I create a project asp.net mvc 5. I migrate all library owin and other in class library. And I use this class library to create user,loggin and other. But now, I see that a mdf is create in app_data and the problem when I create a user or other, the database is not changes and not create.
I think all information are in the mdf file, because if relaunch the application the loggin work. I try many solution on this post: Cannot attach the file *.mdf as database (add/remove attachfile in web.config, stop/delete sqllocaldb) but nothing works.
My web.config is main application(not in library class) is like this:
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(localdb)\v11.0;initial catalog=WebMVCDataBase;integrated security=True;pooling=False;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="userconnection" value="Data Source=(localdb)\v11.0;initial catalog=WebMVCDataBase;integrated security=True;pooling=False;MultipleActiveResultSets=True" />
</appSettings>
and my Application dbcontext is like this:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("userconnection", throwIfV1Schema: false)
{
//Database.SetInitializer<ApplicationDbContext>(new CreateDatabaseIfNotExists<ApplicationDbContext>()); I try this but not work
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
thanks for your help