Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7545467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:56:15+00:00 2026-05-30T08:56:15+00:00

I am trying to get the index replication to work and I can’t seem

  • 0

I am trying to get the index replication to work and I can’t seem to be get it to replicate data to my SQL DB. I have looked at the Docs and the other Stackoverflow item here, but I must be missing something. Can anyone point me in the right direction? I think I am close.

Index “Questions/VoteTotals” does exist in my Raven instance.

Code:

class Program
{
    static void Main(string[] args)
    {
        CreateRdbmsSchema();

        using (var documentStore = new DocumentStore { Url = "http://localhost:8080" }.Initialize())
        {
            documentStore.DatabaseCommands.PutIndex("Questions/VoteTotals",
                                                    new IndexDefinitionBuilder<Question>
                                                    {
                                                        Map = questions => from question in questions
                                                                           select new
                                                                           {
                                                                               question.Title,
                                                                               VoteCount = question.Votes.Count
                                                                           }
                                                    },
                                                    overwrite: true);

            using(var s = documentStore.OpenSession())
            {
                var q = new Question
                {
                    Id = "questions/6",
                    Title = "How to replicate to SQL Server!?",
                    Votes = new List<Vote>
                    {
                        new Vote {Up = true, Comment = "Good!"},
                        new Vote {Up = false, Comment = "Nah!"},
                        new Vote {Up = true, Comment = "Nice..."},
                        new Vote {Up = false, Comment = "No!"},
                    }
                };



            var replicationDocument = new Raven.Bundles.IndexReplication.Data.IndexReplicationDestination
                {
                    Id = "Questions/VoteTotal",
                    ColumnsMapping =
                        {
                            {"Title", "Title"},
                            {"UpVotes", "UpVotes"},
                            {"DownVotes", "DownVotes"},
                        },
                    ConnectionStringName = "Reports",
                    PrimaryKeyColumnName = "Id",
                    TableName = "QuestionSummaries"
                };


                s.Store(q);
            s.Store(replicationDocument);
                s.SaveChanges();
            }

        }
    }

    private static void CreateRdbmsSchema()
    {
        var connectionStringSettings = ConfigurationManager.ConnectionStrings["Reports"];
        var providerFactory = DbProviderFactories.GetFactory(connectionStringSettings.ProviderName);
        using (var con = providerFactory.CreateConnection())
        {
            con.ConnectionString = connectionStringSettings.ConnectionString;
            con.Open();

            using (var dbCommand = con.CreateCommand())
            {
                dbCommand.CommandText = @"IF OBJECT_ID('QuestionSummaries') is not null 
                                                DROP TABLE [dbo].[QuestionSummaries]
                                        ";
                dbCommand.ExecuteNonQuery();

                dbCommand.CommandText = @"CREATE TABLE [dbo].[QuestionSummaries]
                                        (
                                                [Id] [nvarchar](50) NOT NULL,
                                                [VoteCount] [int] NOT NULL,
                                                [Title] [nvarchar](255) NOT NULL
                                        )
                                        ";
                dbCommand.ExecuteNonQuery();
            }
        }
    }
}


public class Question
{
    public string Id { get; set; }
    public string Title { get; set; }

    public List<Vote> Votes { get; set; }
}

public class Vote
{
    public bool Up { get; set; }
    public string Comment { get; set; }
}

EDIT

Per Ayende’s suggestion I added

<connectionStrings>
  <add name="Reports" providerName="System.Data.SqlClient" connectionString="Data Source=.\sqlexpress2008r2;Initial Catalog=Test;Integrated Security=True"/>

To the Raven.Server.exe.config file, but still having issues.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:56:17+00:00Added an answer on May 30, 2026 at 8:56 am

    Scarpacci,
    You probably didn’t add the connection string to the server app.config.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get the z-index to work in my HTML code. I
I have a paginate I am trying to get the index page from an
I have a paginate I am trying to get the index page from an
I am trying to get a guest book to work using PHP. I have
I have the following snippet of code. I'm basically trying to get the index/iterator
I have been trying to get this to work. Basically I have a search
I'm trying to get data from a web-page into my sidebar gadget via: $.get(http://localhost/index.php,
I'm currently trying to get hold of my NSMutableArray 's index depending on one
I am trying to submit a form with method GET and action index.php?id=3. The
I am trying get Struts 2 and Tiles to work and I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.