Real World API Design Using The Entity Framework Services
dotNetDave Conference DVD!Packed full of:Videos of all sessions from 2010 & 2011(1)!Slide decks from 2011 & 2010!Demo projects from 2011 & 2010!David McCarter’s .NET interview Questions!ExtrasConference Photos from 2010!Surprise videos!Book + DVD $25!Only $15!
Check Out Your Local User Groups!San Diego Cloud Computing User Groupwww.azureusergroup.com/group/sandiegoazureusergroupSan Diego .NET Developers Groupwww.sddotnetdg.orgSan Diego .NET User Groupwww.sandiegodotnet.comSan Diego SQL Server User Groupwww.sdsqlug.org
Overview
Current ProblemPartnerCompanyData StoreInternetAll Data Stored in local Data CenterCustomers/ Partners do not have access to dataNo ability to create “add-ins” to applicationNo ability to “upsell” products
PartnerCompanyData StoreInternetImmediate access to the network data for partnersProvide customers with an ever growing wealth of tools for extending applicationMarketing ExposureHandle billing and purchasing transactions with the end-userBusiness Proposition
GoalsMake it easy to access dataAccess to data from any applicationWindowsWebiPhone…Track UsageFor billing Detect abuse
GoalsProvide ability for different application typesVisual ApplicationSurface partner application inside of company applicationData ApplicationAllow data access to authorized customersComposite ApplicationCombination of Visual and Data
ChallengesCurrent database designVery ConfusingSame data in multiple tables.Allow secure access to dataApp can only access a select number of servicesApp can only access data for authorized customersAccess data from multiple locationsSome customers store data locally
Design
Database IssuesHundreds of tables.Tables can have hundreds of columns (some not used anymore)Same data is stored in different tables.Tables store multiple types of data.Primary data keys duplicated in almost every table.Too much expertise needed to understand database.
Database SolutionDesign model of how data should look, regardless of how it’s currently structured
Database SolutionUse Views instead of TablesAllows creating data structures that make more sense, easier to use.Allows splitting/ combining of data from Tables.Allows renaming of columns that make data more understandable/ consistency.Use stored procedures to insert/ update data
Database SolutionUse Entity Framework 4 to implement object model on top of ViewsEasy for developers to use/ understandSeparate models by purposeEasier to deal withRe-use views in different models (sparingly)Remove properties that don’t make sense in modelInsert/ updates only through “main” EntityUse POCO T4 templateEasy to separate entities from data accessCan add functionality/ business logicSmaller payloads across the wire
Exposing Data to PartnersExpose services via HTTPsUse WCF Data ServicesExpose data via REST (JSON and AtomPub)	Easy to expose ModelsOne model per serviceControl Entity access using EntitySetAccessRule
Exposing Data to PartnersUse WCF Data Services	Limit number of records returned using EntitySetPageSizePrevent partners from access to clients that have not “enabled” the applicationModify data coming into service using ChangeInterceptor’sCan also update date in multiple Entities
SecurityLimit partners access to data/ servicesValidate call is from authorized partnerUsing certificate or tokenValidate clientValidate partner has access to service.Validate client/ appValidate appValidate app is activeValidate app access to client
SecurityUse WCF Message InspectorsIntercept service call before it hits the serviceDifferent Message Inspectors for different types of servicesGeneral services uses certificationClient data services uses tokenSmaller than a certificationAuthentication done by calls to back-endAlso used for logging partner usage dataWhat they are hittingPayload sizes
Summary
ChallengesEF does better with “properly” designed databasesEF designer can easily screw up models (better in EF 4)WCF Data Services can be limitingHave to jump through a few hoops to have WCF Data Services to expose entities from a separate projectHave to manually edit .svc files to use Message Inspectors
ChallengesBad REST Queries = Bad SQL QueriesDemands more processing power on the web tierMajority of programmers have never used REST/ LINQ to RestMore of a challenge with other languages (mostly because samples are written in .NET 4)
Looking ForwardAllow more write access to dataProvide “batch” processingFaster data access on first hitAllow read/write access to Entity per appCreate new database from cleaned up model (far in the future)Better configuration, security, logging and developer portal using third-party vendor
Real World API Design Using The Entity Framework Services

Real World API Design Using The Entity Framework Services

  • 1.
    Real World APIDesign Using The Entity Framework Services
  • 3.
    dotNetDave Conference DVD!Packedfull of:Videos of all sessions from 2010 & 2011(1)!Slide decks from 2011 & 2010!Demo projects from 2011 & 2010!David McCarter’s .NET interview Questions!ExtrasConference Photos from 2010!Surprise videos!Book + DVD $25!Only $15!
  • 4.
    Check Out YourLocal User Groups!San Diego Cloud Computing User Groupwww.azureusergroup.com/group/sandiegoazureusergroupSan Diego .NET Developers Groupwww.sddotnetdg.orgSan Diego .NET User Groupwww.sandiegodotnet.comSan Diego SQL Server User Groupwww.sdsqlug.org
  • 6.
  • 7.
    Current ProblemPartnerCompanyData StoreInternetAllData Stored in local Data CenterCustomers/ Partners do not have access to dataNo ability to create “add-ins” to applicationNo ability to “upsell” products
  • 8.
    PartnerCompanyData StoreInternetImmediate accessto the network data for partnersProvide customers with an ever growing wealth of tools for extending applicationMarketing ExposureHandle billing and purchasing transactions with the end-userBusiness Proposition
  • 9.
    GoalsMake it easyto access dataAccess to data from any applicationWindowsWebiPhone…Track UsageFor billing Detect abuse
  • 10.
    GoalsProvide ability fordifferent application typesVisual ApplicationSurface partner application inside of company applicationData ApplicationAllow data access to authorized customersComposite ApplicationCombination of Visual and Data
  • 11.
    ChallengesCurrent database designVeryConfusingSame data in multiple tables.Allow secure access to dataApp can only access a select number of servicesApp can only access data for authorized customersAccess data from multiple locationsSome customers store data locally
  • 12.
  • 13.
    Database IssuesHundreds oftables.Tables can have hundreds of columns (some not used anymore)Same data is stored in different tables.Tables store multiple types of data.Primary data keys duplicated in almost every table.Too much expertise needed to understand database.
  • 14.
    Database SolutionDesign modelof how data should look, regardless of how it’s currently structured
  • 15.
    Database SolutionUse Viewsinstead of TablesAllows creating data structures that make more sense, easier to use.Allows splitting/ combining of data from Tables.Allows renaming of columns that make data more understandable/ consistency.Use stored procedures to insert/ update data
  • 16.
    Database SolutionUse EntityFramework 4 to implement object model on top of ViewsEasy for developers to use/ understandSeparate models by purposeEasier to deal withRe-use views in different models (sparingly)Remove properties that don’t make sense in modelInsert/ updates only through “main” EntityUse POCO T4 templateEasy to separate entities from data accessCan add functionality/ business logicSmaller payloads across the wire
  • 19.
    Exposing Data toPartnersExpose services via HTTPsUse WCF Data ServicesExpose data via REST (JSON and AtomPub) Easy to expose ModelsOne model per serviceControl Entity access using EntitySetAccessRule
  • 20.
    Exposing Data toPartnersUse WCF Data Services Limit number of records returned using EntitySetPageSizePrevent partners from access to clients that have not “enabled” the applicationModify data coming into service using ChangeInterceptor’sCan also update date in multiple Entities
  • 23.
    SecurityLimit partners accessto data/ servicesValidate call is from authorized partnerUsing certificate or tokenValidate clientValidate partner has access to service.Validate client/ appValidate appValidate app is activeValidate app access to client
  • 24.
    SecurityUse WCF MessageInspectorsIntercept service call before it hits the serviceDifferent Message Inspectors for different types of servicesGeneral services uses certificationClient data services uses tokenSmaller than a certificationAuthentication done by calls to back-endAlso used for logging partner usage dataWhat they are hittingPayload sizes
  • 27.
  • 28.
    ChallengesEF does betterwith “properly” designed databasesEF designer can easily screw up models (better in EF 4)WCF Data Services can be limitingHave to jump through a few hoops to have WCF Data Services to expose entities from a separate projectHave to manually edit .svc files to use Message Inspectors
  • 29.
    ChallengesBad REST Queries= Bad SQL QueriesDemands more processing power on the web tierMajority of programmers have never used REST/ LINQ to RestMore of a challenge with other languages (mostly because samples are written in .NET 4)
  • 30.
    Looking ForwardAllow morewrite access to dataProvide “batch” processingFaster data access on first hitAllow read/write access to Entity per appCreate new database from cleaned up model (far in the future)Better configuration, security, logging and developer portal using third-party vendor