0

I'm building an application that will be exposed to the public. So the database will be filled with data. I'm not sure how to extend the model afterwards. Locally after any changes of the model the database get's recreated. How can add properties to the existing model, without recreate the entire database ?

8
  • So long as you abstract away the actual database entities with a business layer, changes to the underlying schema won't necessarily affect your models. Commented Aug 14, 2014 at 21:48
  • I like to change my models. It just don't want to recreate the entire database. Commented Aug 14, 2014 at 21:52
  • Why would changing your models cause the database to be recreated? If you're using code-first then what you're likely referring to as models are what I'm referring to as entities. You'll need to abstract it down another layer if you plan on making changes without causing entity framework to recreate your database every time. Though, it sounds like you're a bit new to databases in general. It might be worthwhile to read up on them before moving forward. Commented Aug 14, 2014 at 21:59
  • @JoshuaShearer, a thing I like to do is to add a meaningfull ToString to the generated classes (in database first) Commented Aug 14, 2014 at 22:04
  • Well now I'm confused. Overriding the ToString method should't cause the database to be recreated; the schema wouldn't have changed as a result of that addition. Commented Aug 14, 2014 at 22:11

1 Answer 1

1

Take a look at EntityFramework CodeFirst Migration, for modifying your schema.

MSDN Link for Migrations

Sign up to request clarification or add additional context in comments.

2 Comments

I'm not sure. Maybe there is a better solution. Waiting. If not accept.
I'm not sure how OP intends to maintain his data in an RDBMS if he keeps changing the definition of his data. Migrations are pretty much the only way to go. OP and NoSQL sound like a match made in heaven.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.