SqlConnection错误:50

时间:2017-12-14 17:08:31

标签: asp.net-core dbcontext sqlconnection

当PM>我收到此错误更新数据库

  

建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。 (提供程序:SQL网络接口,错误:50 - 发生本地数据库运行时错误。无法创建自动实例。请参阅Windows应用程序事件日志以获取错误详细信息。

我的连词代码在这里:

public void ConfigureServices(IServiceCollection services)
    {
        // Add framework services.

        services.AddMvc();
        services.AddDistributedMemoryCache();
        services.AddSession();
        var connection = @"Server=(localdb)\mssqllocaldb;Database=MVCLoginDB;Trusted_Connection=True;";
        services.AddDbContext<OurDbContext>(options => options.UseSqlServer(connection));
        services.AddMvc();
    }

有什么建议吗?

0 个答案:

没有答案