entity framework - EF6 - Code First - Are property mappings needed? -


i have been reading on code first approach entity framework. unfortunately can't find documentation relates ef4 on this. docs have read (scott gu's blog on ef4) indicate don't need mappings.

so generated code files existing database using ef6 power tools generates model classes , mappings folder. automatically looked @ mappings files in there using fluent api (i think correct) , describe details tables.

now reading makes sense possibly wouldn't know primary key, required properties, relationships thing don't property column mappings blog post these not needed why need them?

i can understand needing them if column name can't represented in code naming conventions don't allow this.

my main reason asking maintainability question rather have code particular property in 1 place , these lines this.property(t => t.id).hascolumnname("id"); seem redundant me.

any 1 helpful links on ef6 code first approach appreciated google failing :)

you don't need property mappings if you're satisfied default column names , on. may need them things setting order of columns in compound primary key, or specifying property contains database-generated value (like identity/autoincrement column), can leave column names out of , stick defaults.

column mappings have uses, i'm not sure of them relevant situation:

  • you can map entities existing database without having mimic column names, may not follow standard .net naming conventions.

  • similarly, can follow different naming conventions in code vs. in database. example, work, database columns expected camelcase, not pascalcase.

  • they allow change names of properties @ later date without having recreate/migrate database.

if none of apply you, yeah, think you're fine without them.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -