简体   繁体   中英

Publishing ASP MVC 5 code-first EF along with it's localdb

I have an ASP MVC 5 application using Code First EF. I am setting up an environment to debug on a remote machine and follow these steps.

The website itself publishes fine, but I'm needing to publish the EF local databases along with it as well, content included. I've been digging around online but have had difficulty finding a step-by-step process for doing this that also allows for EF code first updates to the remote database.

Any help would be appreciated.

As for connection , try modifying the connection string in webConfig. As for the information, I'm not 100% sure on this, but I'd you think you would be able to backup the database and restore on the remote machine.

There is a _migrationHistory table in the database that EF refers to when checking the models against the database, so by restoring the whole database (and the _table as the result ) EF should not lose its state ( you won't need to run Update-Database).

If you publish to a server, you can use different appsettings for development and production using different web.config-files as described here

And for your database:

I pretend you want some content of your database being transferred into the production database in addition to get the right structure of tables too.

In this case, Migrations could do the job: If you create your database with CodeFirstMigrations you can be sure, that your structure is right, by migrating the database before publishing.

And for the data, you can use a Database-Initializer to get the required data into any database your targeting as long you have enough permission for this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM