EF4 Code-First causes InvalidOperationException EF4 Code-First causes InvalidOperationException database database

EF4 Code-First causes InvalidOperationException


I know that it is to late for answer, but this post is high on Goolge and answer may be useful for someone. The problem is missing credentials. To prevent this you need to change your connection string to have:

Trusted_Connection=False;Persist Security Info=True

Based on this article


As requested I am posting my comment as an answer.

My solution was very similar to bizon where the Trusted_Connection and Persist Security Info needed correction but I accomplished it through visual studio properties by going to:

Server Explorer -> Modify Connection -> Advanced -> Then check both Persist Security Info and TrustServerCertificate as True, and it formatted the connection string correctly

screenshot of visual studio gui


Just run into this problem while I follow this under VS2012 and EF6. My solution is quite simple:

In the Connection Properties dialog which pops up when choosing "Reverse Engineer Code First", check "Save my password".

Problem solved, but I don't know the details about it...