Using EF 6 and Devart Entity Design and DotConnect for SQLite. I am having issues with the embedded database location when running in debug, release and after installed.

It works just fine to copy the database file to bin/Debug or bin/release and access the database using:

Code:
Data Source=database.db
in my connection string. When I run while debugging I can access the database just fine. IF I install I cannot access the database with read/write - just read only.

So...I have made the app make sure that the database (and a few other resources are available in user directory\AppData\Roaming by running this on form load:

Code:
        string basePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\ThermalVision\";

        //Later...

            if(!File.Exists(basePath + "database.db"))
        {
            string source = AppDomain.CurrentDomain.BaseDirectory + "database.db";
            File.Copy(source, basePath + "database.db");
        }
This works fine as well when running in debug mode inside Visual Studio.

My metadata connection string currently looks like this (code is generated by Entity Developer):

Code:
    public Entities() : 
        base(@"metadata=DataModel1.csdl|DataModel1.ssdl|DataModel1.msl;provider=Devart.Data.SQLite;provider connection string=""Data Source=C:\Users\erics\AppData\Roaming\ThermalVision\database.db;FailIfMissing=False""", "Entities")
    {
        this.ContextOptions.LazyLoadingEnabled = true;
        OnContextCreated();
    }
When this app is installed and I start I get the following error:

HTML Code:
System.Data.Entity.Core.MetadataException: The specified metadata path is not valid. A valid path must be either an existing directory, an existing file with extension '.csdl', '.ssdl', or '.msl', or a URI that identifies an embedded resource. at System.Data.Entity.Core.Metadata.Edm.MetadataArtifactLoader.Create(String path, ExtensionCheck extensionCheck, String validExtension, ICollection1 uriRegistry, MetadataArtifactAssemblyResolver resolver) 
  at
  System.Data.Entity.Core.Metadata.Edm.MetadataCache.SplitPaths(String
  paths)    at
  System.Data.Entity.Core.Common.Utils.Memoizer2.<>c__DisplayClass2.b__0() at System.Data.Entity.Core.Common.Utils.Memoizer2.Result.GetValue()

  at System.Data.Entity.Core.Common.Utils.Memoizer2.Evaluate(TArg arg) at System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetArtifactLoader(DbConnectionOptions effectiveConnectionOptions) at System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetMetadataWorkspace(DbConnectionOptions effectiveConnectionOptions) at System.Data.Entity.Core.EntityClient.EntityConnection.GetMetadataWorkspace() at System.Data.Entity.Core.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection() at System.Data.Entity.Core.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor, ObjectQueryExecutionPlanFactory objectQueryExecutionPlanFactory, Translator translator, ColumnMapFactory columnMapFactory) at System.Data.Entity.Core.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName) at Model.Entities..ctor() at ThermalVision.Form1.SetMachineTextBoxOptions() at ThermalVision.Form1.Form1_Load(Object sender, EventArgs e) at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I am not sure how to resolve this. My path is hard coded and the database connects just fine when I test it in Entity Developer.

It also seems that the other question here is how to handle read/write embedded resources when the resources are using in debugging mode in Visual Studio and in product when the app is installed?