How to add entity-framework to console application (images are included)

痴心易碎 提交于 2019-12-01 04:12:21

I did the same steps you did to setup a EF model. your database.mdf file has the Copy to Output Directory set to Copy always, that means that every time you hit F5 (build or debug your app) the file is getting replaced by the empty one on your project.

Changing the Copy to Output Directory on the Properties window of the mdf file should solve your problem.

If you use Copy if newer you are going to be persisting any modifications on the contents of the database until you edit the database (mdf) itself.

With Do not copy any change to the mdf file is not going to get reflected on your application and will probably generate problems with EF.

I recommend for this scenario that you use Copy if newer and fill your basic data in the mdf file so you will have it always available.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!