0

ASP.Net Mvc automatically generate User Database when you create internet project. I want the tables from this database to be created automatically again but on my database. How can be done this ?

I think this database is automatically created on

<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-AccountPortal-20131128183241;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-AccountPortal-20131128183241.mdf" providerName="System.Data.SqlClient" />

I want to be created on my connection string. So I can be able to see the tables.

0

1 Answer 1

2

Change

public class UsersContext : DbContext
{
    public UsersContext()
        : base("DefaultConnection") //<--- change it to your connectionstringname
    {
    }

    public DbSet<UserProfile> UserProfiles { get; set; }
}

change DefaultConnetion to the connection string name that you want these tables to be created.

Sign up to request clarification or add additional context in comments.

2 Comments

So if I change the connection string. These tables will be created automatically ?
yes you can change the connection string too.EF code first will automatically generate the tables. if not then use migration to generate the tables. msdn.microsoft.com/en-us/data/jj591621.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.