Entity Framework 4.3 Hosted SQL Server No Database Create Permissions

此生再无相见时 提交于 2019-12-25 00:25:12

问题


My SQL Server is hosted by my hosting provider. This means that I don't have permission to recreate (or create) the database.

This is causing me a problem with EF 4 - it thinks the tables are missing, which they are. I think is caused by not being able to recreate the database.

To recap: developed locally, moving to hosted server for first time run, switched the connection string, run against the hosted server, error saying Invalid object name 'dbo.Products'.

I have permission to create anything else apart from the DB

Am I correct in this assumption and how do I work around this?


回答1:


In EF 4.3 you can use the Package Manager Console from the tools menu item in visual studio. This will allow you to use migrations to generate a DB script. More info here

http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-code-based-migrations-walkthrough.aspx

You could of course create a drop and create script yourself




回答2:


You can create the database manually and set the Database.SetInitializer(null) or you could try the EF 5 RC. In the release notes you can read that they solved this issue.



来源:https://stackoverflow.com/questions/11135823/entity-framework-4-3-hosted-sql-server-no-database-create-permissions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!