EntityFramework update existing records with new foreign key
<p>I have a database and a set of tables that already have data in.
I am using code first. Now I have been asked to add a <strong>Category</strong> table to the database and with that, to change some of the other tables to reference that table via a foreign key.
I know through previous experience, that if I update the database after changing the models, it will moan because an FK can't have 0.
So I want to use the <strong>Seed</strong> method to actually update the Foreign Keys as the database is updated.</p>

<p>I want to do something like this:</p>

<pre><code>protected override void Seed(DatabaseContext context)
{

    // Create our categories
    context.Categories.AddOrUpdate(m =&gt; m.Id,
        new Category { Id = 1, Name = "Cameras" },
        new Category { Id = 2, Name = "Televisions" }
    );

    // Get all our current feeds
    var feeds = context.Feeds.ToList();
    context.Feeds.AddOrUpdate(m =&gt; m.Id, feeds.Select(m =&gt; m.CategoryId = 1).ToArray());
}
</code></pre>

<p>Can someone let me know how I might actually do this? Or if there is another way of doing it?</p>