当前位置: 动力学知识库 > 问答 > 编程问答 >

.NET embedded SQLite database file on deployment

问题描述:

I am deploying the .NET/WPF application that uses SQLite database as back-end and Entity Framework for CRUD operations with that file.

I want that the end users after installing the application will have that SQLite file on they local computer (is it /Users/xxxx/AppData/Roaming/MyApp or something else ?).

During the development I have had the SQLite file located on my local folder and everything has worked fine. How do I configure the application before deploying it to get that result?

网友答案:

I found a great answer from another question: %APPDATA% in connection string is not substituted for the actual folder?

What was needed was:

  1. Changing connection string to include |DataDirectory| in the path to the database file and;
  2. Providing the value for |DataDirectory| in the application Main method

    AppDomain.CurrentDomain.SetData("DataDirectory", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData))

分享给朋友:
您可能感兴趣的文章:
随机阅读: