visual studio 2012 - POCO Class in EF not working as Expected -


i have created database in sql , created edmx in visual studio 2012. automatically created poco (tt) classes. looks fine.

now change column name of table. update edmx. opening edmx in xml , looks fine.

question 1

after ran custom tool in tt, see new property got created additionally, e.g.:

sql table name : student  column name : sname 

in poco class

public int sname{ get; set; } 

got automatically created.

now change column name in sql

column name : studentname 

my poco class

public int sname{ get; set; }  public int studentname{ get; set; } 

is bug or need fix this?

what should avoid this?

question 2

also, if change data type of sql column , update model db in edmx designer, conceptual model not updated. how go this?

first, understand problem, need know edmx file xml file contains 3 different sections:

  • csdl: conceptual schema definition language
  • ssdl: store schema definition language
  • msl: mapping specification language

the csdl contains entities , relationships make conceptual model. ssdl describes db model , msl mapping between 2.

the “update model db” process update ssdl (change inconsistent current db schema), modify csdl in case you’ve added new things db schema.

this quite normal behavior since conceptual schema may/should differ db schema (unless want domain model db model not sound oop/ddd best practices).

as @peru, solution delete concerned entity (not entire edmx!) , perform “update model db” process.

hope helps!

edit:

there's tool, not free, visual studio plugin allows apply changes made db, both on csdl , ssdl files: huagati dbml/edmx tools. "free" solution deleting entity (or right field within entity) needs updated.

remember csdl supposed maintained developers , must object model rather db model. imagine have setup inheritance between entities or have split 1 db table 2 edmx entities, running "update model db" should not overwrite everything!


Comments