c# – 如何使用数据库释放WPF

我正在使用实体框架,现在想要发布软件 – 它附加了一个数据实体模型,它作为localhost托管在开发PC上.有没有办法可以释放它,然后它会保留数据库?每次我发布它然后打开程序崩溃;当我发布它时,我很快就会在任何数据库...

我正在使用实体框架,现在想要发布软件 – 它附加了一个数据实体模型,它作为localhost托管在开发PC上.

有没有办法可以释放它,然后它会保留数据库?

每次我发布它然后打开程序崩溃;当我发布它时,我很快就会在任何数据库代码上出现红线错误,然后消失.

任何帮助,将不胜感激.

Edit: Does the Database have to be hosted online?

Edit: It does not crash when I run it in debug mode and it works fine

Edit: I have moved the .exe file onto my Desktop only (not sure if I had to take the whole release file)

Edit: Here is a PrintScreen:

解决方法:

如果您使用的是Entity Framework,那么您的程序将需要这些程序集以及它所依赖的任何其他程序集与.exe文件位于同一文件夹中.可能解释为什么它在Debug中工作正常. Visual Studio会将依赖项复制到输出文件夹中.

本文标题为:c# – 如何使用数据库释放WPF