There is no way on earth this is supposed to be this hard. For 30 hours straight I have been trying to populate a code first database with data. I have tried using a sql server compact instance and a sql server express instance.
I am working with Visual Studio 2010 sp1 and my sql server is SQL Server 2008 R2 (express). Firstly, any database created by the EF I cannot open with management studio. Any database created with the correct schema by management studio cannot be hooked up to the visual studio app. I was under the impression if I pointed to that file EF would hook up to it. The schema is correct because I exported it from an EF created DB. However, that does not work and I get an error that the database already exists.
After painstaiking adding data to a EF created db through the visual studio database tools with scripts, the site would not run, I got an error that the database log file was different or the file was corrupted.
If someone could please just tell me how this is SUPPOSED to work, I would appreciate it. The project is ready to go, I just need to load it with production data and get it uploaded, of course it was due yesterday.
Here are some more details if you need them: I use this following line of code in the global asax code file when trying to create db's, and I comment it out when trying to connect to a db: Database.SetInitializer(new storagePropertyInitializer());
A few of the connection strings I have tried:
<add name="storageContext" connectionString="data source=.\SQLEXPRESS;Persist Security Info=False;User ID=xxxx;Password=xxxxx;Database=irrStorage;AttachDBFilename=|DataDirectory|irrStorageV12.mdf;User Instance=true" providerName="System.Data.SqlClient" />
<add name="storageContext" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;Database=storagePropsDB;AttachDBFilename=|DataDirectory|irrStorageProperties.mdf;User Instance=true" providerName="System.Data.SqlClient" />
<add name="storageContext" connectionString="Data Source=|DataDirectory|irrStorageProperties.sdf" providerName="System.Data.SqlServerCe.4.0" />
Thanks, John