C# 将WPF项目链接到Windows Azure数据库

C# 将WPF项目链接到Windows Azure数据库,c#,wpf,database,visual-studio,azure,C#,Wpf,Database,Visual Studio,Azure,我对WindowsAzure比较陌生。到目前为止,我的C#WPF项目(Visual Studio 2012)一直在访问本地数据库。最近设置了一个Windows Azure帐户,我想将本地DB迁移到Azure 我已经在Azure上创建了一个SQL数据库 我正在努力添加C代码,以便将数据从本地应用程序传递到云。为了测试此功能,我添加了一个随机用户,我想将其插入Azure DB 以下是我到目前为止的情况: 在App.config中: <connectionStrings> <a

我对WindowsAzure比较陌生。到目前为止,我的C#WPF项目(Visual Studio 2012)一直在访问本地数据库。最近设置了一个Windows Azure帐户,我想将本地DB迁移到Azure

我已经在Azure上创建了一个SQL数据库

我正在努力添加C代码,以便将数据从本地应用程序传递到云。为了测试此功能,我添加了一个随机用户,我想将其插入Azure DB

以下是我到目前为止的情况:

在App.config中:

<connectionStrings>
   <add name="STAREntites"
        connectionString="Server=tcp:xxxxx.database.windows.net;
                     Database=xxxxx;
                     Uid=xxxxx.database.windows.net;
                     Pwd=xxxxx;
                     Encrypt=Yes;" />
</connectionStrings>
}

在我的注册页面中,我还有以下代码将数据发送到Azure DB:

private void RegisterUser()
    {
             string connStr = ConfigurationManager.ConnectionStrings["STAREntites"].ConnectionString;                           
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connStr);
            CloudTableClient client = storageAccount.CreateCloudTableClient();
            CloudTable table = client.GetTableReference("PersonTable");
            table.CreateIfNotExists();
            var emp = new PersonTable
            {
                FirstName = "Cor",
                LastName = "Mky",
                EmailAddress = "cm@email.com",
                Password = "password",
            };

            TableOperation insertOp = TableOperation.Insert(emp);
            table.Execute(insertOp);

    }
目前,我可以通过服务器资源管理器看到从
RegisterUser
方法添加的测试用户被插入到WindowsAzure存储中的person表中。但是,当我检查Azure SQL数据库时,实体不存在

有人能帮助解释为什么该实体没有被发送到Azure吗


我已经检查了我的端口是否正在侦听以及SQL server是否正在运行。我在VisualStudio中没有收到任何错误

您似乎对存储的类型感到困惑
CloudStorageAccount
用于Azure存储:表、Blob和队列,不用于Windows Azure SQL数据库

我不太确定如果您传递的是类似SQL Server连接字符串的内容,那么
CloudStorageAccount.Parse
如何不会引发错误

如果您想将实体框架与Windows Azure SQL数据库一起使用,只需使用常规的
DbContext
code,并向WASD提供ADO.NET连接字符串,该字符串与您拥有的类似,只是Uid应该是
Uid=uuuuu@xxxxx

如果您想使用表存储,那么您应该在表存储中查看插入的实体,使用类似的方法


.

您的UID看起来很奇怪。应该是“uuuuu@xxxxx".
private void RegisterUser()
    {
             string connStr = ConfigurationManager.ConnectionStrings["STAREntites"].ConnectionString;                           
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connStr);
            CloudTableClient client = storageAccount.CreateCloudTableClient();
            CloudTable table = client.GetTableReference("PersonTable");
            table.CreateIfNotExists();
            var emp = new PersonTable
            {
                FirstName = "Cor",
                LastName = "Mky",
                EmailAddress = "cm@email.com",
                Password = "password",
            };

            TableOperation insertOp = TableOperation.Insert(emp);
            table.Execute(insertOp);

    }