I want to set my existing database TestDB
into my application so that Identity will create their tables inside this database.
But I am getting error:
Cannot attach the file 'D:\TestApp\TestApp\App_Data\TestDB.mdf' as database 'TestDB'.
I have done couple of things which are
I removed
defaultconnection
toTestDBConnection
inweb.config
<add name="TestDBConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\TestDB.mdf;Initial Catalog=TestDB;Integrated Security=True" providerName="System.Data.SqlClient" />
I changed in
IdentityModels.cs
public class ApplicationDbContext : IdentityDbContext<ApplicationUser> { public ApplicationDbContext() : base("TestDBConnection", throwIfV1Schema: false) { }
In package Manager Console,
PM>enable-migrations
In
Configuration.cs
,internal sealed class Configuration : DbMigrationsConfiguration<TestApp.Models.ApplicationDbContext> { public Configuration() { AutomaticMigrationsEnabled = true; }
Please guide me where am I going wrong. I am looking for your suggestions.