Wednesday, 15 June 2011

c# - Entity Framework database-first doesn't create the correct model -



c# - Entity Framework database-first doesn't create the correct model -

i'm trying utilize database-first approach ef 5.0 , doesn't create right model me.

here info structure:

forums

users

posts

relationships

the problem

the main problem one-to-one relationships in forums , posts table. model doesn't recognize parentforumid , replyto nullables , hence creates one-to-many relationship between tables (forum-forum , post-post).

also, when trying manually alter one-to-one relationship, error:

error 113: multiplicity not valid in role 'forum1' in relationship 'fk_forums_forums'. because dependent role properties not key properties, upper bound of multiplicity of dependent role must *. ...\models\entities\model1.edmx

the model in visual studio (before editing)

i tried using code-first approach produced poor database result, realized can configure behaviour of database creation couldn't find resource explains how configure correctly.

i'd rather utilize database-first approach since lets me customize database still generates wrong model many errors.

so question is:

what best approach so?

where can larn code first, database first thoroughly?

why visual studio produce such model?

why when seek alter model fit needs gives me error described before?

where can larn migration tools? functions can utilize configure database creation?

question 1: depends.

if have code written, or prefer write objects first, go route.

if on other-hand, prefer doing db schema first, all-means, that.

it matters not, take what's comfortable you.

c# entity-framework code-first database-first

No comments:

Post a Comment