c# - Using EF with existing database and domain/object model which is not 1:1 -
first of all: i'm ef-newbie, , test capabilities of ef, , see how fits environment set in terms of database tables , object model - , when these 2 models not map 1:1 in terms of class names/table names , attribute names/column names, , number of tables , classes. please maintain "test capabilities" in mind should sense urge reply: "ef not meant used way". thanks! :)
consider next scenario.
i have 3 database tables:
|----------------| |-------------| |-----------------| | messagelog | >---1 | message | 1---< | messagetext | |----------------| |-------------| |-----------------| | logid | | messageid | | messageid | | messageid | | type | | languagecode | | | | ... | | text1 | | | |-------------| | text2 | | ... | | ... | |----------------| |-----------------|
which want map 2 classes:
|--------------------| |----------------------------| | servicemessage |<-\ | servicemessageinstance | |--------------------| | |----------------------------| | id: string | | | id: string | | languagecode: str. | \----| message: servicemessage | | text1: string | | from: datetime | | text2: string | | to: datetime | | type: messagetype | |----------------------------| |--------------------|
servicemessage objects comprised of row message table (with messageid key) , row messagetext table (with messageid , languagecode keys).
servicemessageinstance easier: has reference servicemessage object, , additional attributes.
i have played bit ef, , done lot of googling, have not found reply question: how can create happen ef? approach should take? can edmx designer? dbcontext.onmodelcreating?
i realise might bit "wide" question, appreciate pointers!
thanks.
br, herms
which way go question:-) explained here: http://msdn.microsoft.com/en-us/data/ee712907
to assist you can install entity framework powertools.
http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d
there nice alternative reverse engineer code first db. create new project. on project right click , context menu should offer
you should see code added project. can useful review. deleted temp project. after taking useful parts own code.
good luck
c# entity-framework ef-code-first ef-database-first
No comments:
Post a Comment