In Entity Framework, update the database schema.

.net entity-framework schema

Question

I set up Visual Studio SP1 and experimented with Entity Framework.

I attempted several fundamental operations after creating a schema from an existing database.

All except the database schema modification went well.

I made the following fundamental database changes:

  • a new table was added
  • a table was removed
  • added a column to a table that already existed.
  • removed a column from a table that already existed.
  • the type of an existing column was modified

The first three proceeded without a hitch, however the database modifications were not followed for the type change and column deletion.

Is there a way to get the designer to produce it? Or is it not currently supported? I've not yet discovered any relevant content, but I'm continuing looking.

1
8
8/25/2008 5:05:06 AM

Accepted Answer

Though it's only a speculation on my side, I would venture to say that maybe such don't occur since they would disrupt the build for already-existing code.

Here is my reasoning:

It's conceivable that just because you are removing a column from table A doesn't imply that there shouldn't be a property Description for that entity as EF is designed to be more than a 1:1 table mapping. That attribute may just be mapped to another table.

Second, altering a type can just cause builds to fail. There is simply that justification.

6
8/15/2008 4:18:22 PM

Popular Answer

I've discovered that the 'Update Model from Database' option still has a lot of issues.

Keys are the problem for me; I've never been able to modify a foreign-key relationship or add a primary key to a table and have the updater work correctly (in that it will give a compile error on the generated code) - but to fix the issue, it only takes a minute to delete the model and re-import it. This is obviously not ideal, but I've never had a failure from a 'fresh' import.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow