Note that there are some explanatory texts on larger screens.

plurals
  1. POCan I fix Entity Framework Code First Migrations?
    text
    copied!<p>Background: </p> <p>I'm developing an application with Entity Framework Code First and have been using my POCO Model to describe the database schema as much as I can. However there are a few cases where only the migrations API supports what you want (such as adding an index). I didn't want to start adding migrations until later, it's much faster just to recreate the database at this point, however it seemed like the only option.</p> <p>So I thought I'd see if I could see if migrations would work. I planned on using them eventually and I was hoping I'd just be able to adjust the Initial migration or regenerate it as I went, until it was time to make real migrations. However I had no real luck with this approach either. It seems like code migrations for entity framework are fundamentally flawed in that they force the schema to be stored (serialized) as part of the migration.</p> <p>For me it meant that there was no possible way to adjust the migration as I had no way to update the <code>Target</code> property (which is essentially a serialized version of my model). I also can't regenerate the migration because there is no way to express the indices separately. Part of the problem is that the way migrations work forces them to be made in a serial fashion, which is terrible when I want to update past migrations or there are multiple developers.</p> <p>I've therefore chosen to just use <code>context.Database.ExecuteSqlCommand</code> to add the indices however I want to figure out if this limitation in migrations is going to change in the future or if I can work around it.</p> <p>Question:</p> <p><strong>Is there any way to update the <code>IMigrationMetadata</code> for an existing migration and is there a way to have a migration that doesn't need the metadata found in the <code>Target</code> field?</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload