I have a website I'm developing that uses an SQL Azure database. I want to be able to test my website using a database locally hosted on the debugging machine so that my designer can work on style and content without having to deal with the overhead of firing up the Azure emulator and communicating with an external service as he is often in areas with no-connectivity.
我有一个我正在开发的网站使用SQL Azure数据库。我希望能够使用调试机器上本地托管的数据库来测试我的网站,这样我的设计人员就可以处理样式和内容,而无需处理启动Azure模拟器和与外部服务通信的开销。通常在没有连接的区域。
I imagine it would be possible to extract the .sql scripts to create the database and execute them every test run, but this seems tedious. Similarly I'm not sure what the best way to configure these deployment details would be in order to switch between development, and published configurations. I'm a new web-developer cutting my teeth on a rather large project.
我想可以提取.sql脚本来创建数据库并在每次测试运行时执行它们,但这似乎很乏味。同样,我不确定配置这些部署细节的最佳方法是在开发和发布配置之间切换。我是一个新的网络开发人员,在一个相当大的项目上掏腰包。
Using ASP.NET MVC4 and have MSSQL 2012 installed for what it's worth.
使用ASP.NET MVC4并安装MSSQL 2012以获得它的价值。
1 个解决方案
#1
1
You can export your SQL azure database as .bacpac format and then import it into your sql server database. It will create all tables and fill with data. You don't need to do it on every test run, just do it once and you will have proper database for debug needs.
您可以将SQL azure数据库导出为.bacpac格式,然后将其导入到sql server数据库中。它将创建所有表并填充数据。您不需要在每次测试运行时都执行此操作,只需执行一次,您将拥有适当的数据库以满足调试需求。
Switching between debug and release (or you can rename it if you want, e.g. Local and Production) configurations and using different web.config (or config transformations) is a good way to work with different settings.
在调试和发布之间切换(或者您可以根据需要重命名,例如本地和生产)配置并使用不同的web.config(或配置转换)是处理不同设置的好方法。
If you want to store your db scripts (db structure or data) in your VCS - you can use Entity Framework migrations (new fancy way) or separate project of "SQL Server database" type (old school but proven way :) ).
如果要在VCS中存储db脚本(db结构或数据) - 可以使用Entity Framework迁移(新的花式方式)或单独的“SQL Server数据库”类型项目(旧式但经过验证的方式:))。
Also EF migrations allows you to easily recreate db (with different name) on each run (for unit testing purposes. And then you can use SQL Express file instance (keep in mind that it's only for local work, your designer wont be able to access sql express instances afaik)
此外,EF迁移允许您在每次运行时轻松地重新创建db(具有不同的名称)(用于单元测试目的。然后您可以使用SQL Express文件实例(请记住,它仅用于本地工作,您的设计人员将无法访问sql express instances afaik)
#1
1
You can export your SQL azure database as .bacpac format and then import it into your sql server database. It will create all tables and fill with data. You don't need to do it on every test run, just do it once and you will have proper database for debug needs.
您可以将SQL azure数据库导出为.bacpac格式,然后将其导入到sql server数据库中。它将创建所有表并填充数据。您不需要在每次测试运行时都执行此操作,只需执行一次,您将拥有适当的数据库以满足调试需求。
Switching between debug and release (or you can rename it if you want, e.g. Local and Production) configurations and using different web.config (or config transformations) is a good way to work with different settings.
在调试和发布之间切换(或者您可以根据需要重命名,例如本地和生产)配置并使用不同的web.config(或配置转换)是处理不同设置的好方法。
If you want to store your db scripts (db structure or data) in your VCS - you can use Entity Framework migrations (new fancy way) or separate project of "SQL Server database" type (old school but proven way :) ).
如果要在VCS中存储db脚本(db结构或数据) - 可以使用Entity Framework迁移(新的花式方式)或单独的“SQL Server数据库”类型项目(旧式但经过验证的方式:))。
Also EF migrations allows you to easily recreate db (with different name) on each run (for unit testing purposes. And then you can use SQL Express file instance (keep in mind that it's only for local work, your designer wont be able to access sql express instances afaik)
此外,EF迁移允许您在每次运行时轻松地重新创建db(具有不同的名称)(用于单元测试目的。然后您可以使用SQL Express文件实例(请记住,它仅用于本地工作,您的设计人员将无法访问sql express instances afaik)