Deploying SqlServerCe with an ASP.NET MVC application

Using Entity Framework Code First together with SqlServerCe is a great way to work with small databases in ASP.NET MVC applications. I have several web applications running on shared hosting sites where SqlServerCe is the database engine under the hood. Deploying is also quite easy. I typically use the build in Publish Web option which works great over FTP.



When using SqlServerCe you have to make sure you add the deployable dependencies. Forgetting those results in pretty clear error messages.



However once that is done I always run into another issue. When a page actually tries to use SqlServerCe I will see a security exception:

System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

The solution is simple enough. Go to whatever security portal your provider is using, mine is using Plesk, and make sure the user that is actually running the web site has the required read/write privileges to work with the Bin folder.








Leave a Reply

Your email address will not be published. Required fields are marked *