c# - How to use AspNet.Identity in a Domain Model -


a domain model should model problem domain of application, unaware of aspects of implementation; data access example.

in respect, feels bit dirty adding microsoft.aspnet.identity.entityframework domain model, since domain model should unaware (and not care) i'm going implement using entity framework...

...herein lies problem

in domain model have several classes linked user accounts

example

class profile {     public user owner { get; set; } }  class blogpost {     public user owner { get; set; } } 

the problem user extends identityuser, hence reference entityframework.

the solution can think of replace references user guid, linking owner id

example

class profile {     public guid ownerid { get; set; } } 

again, feels dirty, against oop , not solid

given want elegant-a-solution possible, how can solve this?

i agree identity framework model should seperate other models. , think give answer in question. model complete without implementing identity framework? user not part of domain model part of identity model. however, linking table.

i think best solution create domain user table , relate model table. can use identity framework user guid key. create 1:1 relation between 2 tables.

extend user class (from identity framework) domain user table access domain user table, in case need add or remove user. despite fact domain.user not part of identity framework, can access table without having add table identity framework model itself. add reference in user (identityuser) class.

if not want create new user table can add domain user class (that not extend identityuser) exposes (non-critical) fields want read or update.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -