Why does my ascx.g.cs file disappear?

This time I’ve been fighting with Visual Studio. I’ve been working on a SharePoint solution with administrator’s account and I decided to switch and continue development under my regular account (with privileges of administrator). So I have logged into server with my account and opened my solution. First Visual Studio Error has appeared after few moments:

The Site URL property of the project does not contain a valid URL. To ensure that designers work as expected, set the Site URL property of the project to the URL of a SharePoint server. Close all designers, and then open them again.

I ignored the error as I checked the Site URL property and the property was correctly set. But then I noticed that ascx.g.cs file of my Visual WebPart disappeared and I could not build a solution anymore. I have searched a lot and I found only advices like Site Collection has to exist or has to be accessible for user. But the reason of this issue was that I didn’t have permissions to deploy solution to farm. The same permissions you need when you run Management shell and you see “The farm is not accessible” welcome message. You need to add permissions for your users in SQL.

Leave a comment for: "Why does my ascx.g.cs file disappear?"