I have 2 projects in my solution
- Web UI
- Web API
I am using Web API project for authentication (ASsp.Net Identity Framework). Below is the web.config setting for the connection string in Web.API project
<connectionStrings>
<add name="AuthContext" connectionString="Data Source=./SQLEXPRESS;Initial Catalog=TestDB;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
</connectionStrings>
My DbContext Class
public class AuthContext : IdentityDbContext<IdentityUser>
{
public AuthContext()
: base("AuthContext",throwIfV1Schema:false)
{
}
public static AuthContext Create()
{
return new AuthContext();
}
public DbSet<Client> Clients { get; set; }
public DbSet<RefreshToken> RefreshTokens { get; set; }
}
TestDB is an existing database with few tables. This is what I did in Web API project in the Package Manager Console
- Enable-Migrations
- Add-Migration InitialCreate
- Update-Database
It always create a new database called AuthContext instead of adding the necessary tables in TestDB.
I set the Web UI project as the Startup Project in my solution. How do I get update-database to create tables in TestDb instead of creating of new database.
-Alan-