I want to create a VS 2010 project with EF 4.0 model.
But I have no records and errors after inserting new record with attached .mdf file .But if t开发者_如何转开发he base is connected to Sql Server, it works fine.
Please help me to insert records to attached .mdf db
You need to make sure DB is not in a shared folder, is on your pc, is not read only, that you have write permissions to the folder that contains it and there is no DB already attached to service with same name. Make sure you can connect with Server Explorer window first.
Consider using SQL Server CE, if you want to work with loose DB files.
Also, make sure the file is not overwritten with each build. (Use "Copy if newer", not "Copy always".)
精彩评论