2

I'm creating a WPF application which uses Entity Framework for SQL Server Compact Edition.

I'm getting a SQL error 26, which I can't figure out how to solve, need your help!

This is my xaml where I define my ViewModel as the window DataContext:

xmlns:vm="clr-namespace:Company.App.UI.ViewModels">

<Window.DataContext>
    <vm:ApplicationViewModel />      
</Window.DataContext>

When I do it this way I get squibbly lines under VM:ApplicationViewModel and see the following error:

A network-related or instance-specific error occurred while establishing a connection to the 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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

If I define my DataContext in code behind I get no errors.

My solution can run and build just fine, but my xaml designer is extremely slow when this error is present.

I'm using SQL Server CE so I can't figure out why I'm getting this error.

My connection string looks like this:

<add name="AppContext"
     providerName="System.Data.SqlServerCe.4.0"
     connectionString="Data Source=|DataDirectory|\AppDb.sdf" />

All existing answers to this error (for SQL Server CE users) seems to suggest that the connection object is wrong (ie, use SqlCeConnection instead of SqlConnection). But I'm not defining a connection in my code (I think EF takes care of that).

4

0 に答える 0