views:

97

answers:

2

Hi, in early development stages the database is subject to continuous changes. I'm toying around with LinqToSQL and in most cases the Entity Model is just a 1:1 representation of the DB.

How can i keep the model up to date with the db changes?

Thanks.

+1  A: 

I noticed that there is an "update model from database" command available if you right-click the Entity Framework design surface. I couldn't find such a thing for LINQ to SQL, so you might have to maintain by hand.

OTOH, it's just XML, so you could "just write some code".


The other thing to add is that I prefer the fact that in EF, I don't have to keep up to date with the physical database. I'm defining the entities that developers will use to access the data, and separately I'm defining the mapping between those entities and the logical database structure.

They don't need to be the same. If I want to split a table into two, or combine two entities into one table, I can do this, without requiring developers to rewrite their code.

John Saunders
+1  A: 

Might have to do something like what is explained here. But personally I prefer the entity framework (ADO.net entities are supported by default, and can be updated with a simple right-mouse click).

//edit

Seems that a simple drag&drop will also work.

For some people, this question is moot. It’s easy enough to utilize the current “resync” mechanism in LINQ to SQL by deleting all the entity classes and functions (the LINQ to SQL term for sprocs and UDFs) on the designer surface and then redragging and dropping the tables and functions of interest, thus updating the entity classes by regenerating from scratch. However, for others, this solution is not good enough for a few reasons:

which you can read here.

bastijn