Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLLocalDB Supported? #1143

Closed
mbalatha opened this issue Mar 12, 2024 · 5 comments
Closed

SQLLocalDB Supported? #1143

mbalatha opened this issue Mar 12, 2024 · 5 comments

Comments

@mbalatha
Copy link

Hi there, I'm trying to synchronize between SQL Server and SQLLocalDB. However, I'm encountering an exception that says, "Specified LocalDB instance name is invalid." Below is the full exception and code. Any thoughts or assistance would be appreciated.

Exception Details:

Dotmim.Sync.SyncException
  HResult=0x80131500
  Message=[NeedsToUpgradeAsync]..[GetConnectionAsync]..A network-related or 
instance-specific error occurred while establishing a connection to SQL Server. The server 
was not found or was not accessible. Verify that the instance name is correct and that 
SQL Server is configured to allow remote connections. 
(provider: SNI_PN11, error: 50 - Local Database Runtime error 
occurred. **Specified LocalDB instance name is invalid.**
)
  Source=Dotmim.Sync.Core
  StackTrace:
   at Dotmim.Sync.SyncAgent.<SynchronizeAsync>d__28.MoveNext()
   at Dotmim.Sync.SyncAgent.<SynchronizeAsync>d__28.MoveNext()
   at Try.DotmimSync.SyncProvider.<StartSyncAsync>d__0.MoveNext() in 
   at Program.<<Main>$>d__0.MoveNext() in Program.cs:line 7

Inner Exception 1:
SqlException: A network-related or instance-specific error occurred 
while establishing a connection to SQL Server. The server was not 
found or was not accessible. Verify that the instance name is correct 
and that SQL Server is configured to allow remote connections. 
(provider: SNI_PN11, error: 50 - Local Database Runtime error 
occurred. Specified LocalDB instance name is invalid.
)

Inner Exception 2:
Win32Exception: Unknown error (0x89c5011b)

Code:

public async Task StartSyncAsync()
{
    // Sql Server provider, the "server" or "hub".
    SqlSyncProvider serverProvider = new SqlSyncProvider(
        @"UID=dbuser;PWD=******;Server=10.0.0.1;Database=EmployeesServerDB");

    SqlSyncProvider clientProvider = new SqlSyncProvider(
        @"Server=(localdb)\\MSSQLLocalDB;Database=EmployeesClientDB;Integrated Security=True");

    var tables = new string[] {
        "Employees"};

    // Tables involved in the sync process:
    var setup = new SyncSetup(tables);

    // Sync agent
    SyncAgent agent = new SyncAgent(clientProvider, serverProvider);

    do
    {
        var result = await agent.SynchronizeAsync(setup);
        Console.WriteLine(result);

    } while (Console.ReadKey().Key != ConsoleKey.Escape);
}
@mbalatha mbalatha changed the title SQLLocalDB Supported SQLLocalDB Supported? Mar 12, 2024
@BluePalmTree
Copy link

Hi, we use LocalDb all the time during development and it works great. This seems more like a problem with the ConnectionString or the SQLLoclDb Instance itself.

@mbalatha
Copy link
Author

Thanks, @BluePalmTree, for your response. I just wanted to clarify that it's not SQL Server Express; it's SQL Server Express LocalDB. You can find a related article here.

@mbalatha
Copy link
Author

@BluePalmTree Any thoughts?

@MohrWizard
Copy link

@mbalatha I use dms in production to sync a Sql server with many client LocalDb instances and it works like charm. I have some suggestions for you:

  1. LocalDb works with SqlSyncProvider, I haven't tried it with SqlSyncChangeTrackingProvider.
  2. I use EF Core migrations to create the LocalDb instance on the client and only then I use DMS to sync, I don't know if Dms can create an instance from scratch like it does for SQLite.

@Mimetis
Copy link
Owner

Mimetis commented Apr 9, 2024

  1. LocalDb works with SqlSyncProvider, I haven't tried it with SqlSyncChangeTrackingProvider.

LocalDb works with both, as it's a SQL engine, like any other (EXPRESS, AZURE etc ...)

Be sure you have a proper connection string like this one:

Data Source=(localdb)\mssqllocaldb; Initial Catalog=myDB; Integrated Security=true;MultipleActiveResultSets=False; 

@Mimetis Mimetis closed this as completed Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants