mardi 12 janvier 2016

How to set the UNC path in the path of the sqlite database?

In this post, I asked if it was possible to set the path of the Sqlite database if this database is in a sahred folder. The answer was that it is possible, just I have to set the UNC path when I am instantiating the connection.

Well, I have tried this with this code (I am using EF7, I guess that is the same than using Sqlite.net-PCL because in this case the code that I have readed is the same).

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            string dataBasePath = @"\\MyremotePC\d\myDatabase.sqlite3";
            try
            {
                _databasePath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path,
                dataBasePath);
            }
            catch (InvalidOperationException)
            {
                throw;
            }

            optionsBuilder.UseSqlite($"Data source={dataBasePath}");
        }

The exception that I get is that the database is not found.

I am sure that I have access to the database because I set the "all user" permissions for full control.

Thanks.

Aucun commentaire:

Enregistrer un commentaire