linq to sql - SqlMetal generating garbage association names -
Why are you messing with the names of the SQLMalal Association? For example, in my 'Text Message' table, I have two columns reference 'ApplicationUser' table. 'SenderUserId' and 'RecipientUserId'
When I run SqlMetal and look at my 'ApplicationUser' class
Generates this for 'RecipientUserId':
< Pre> [Association (name = "FK__TextMessa__Recip__72910220", storage = "_ TextMessages", ThisKey = "ID", OtherKey = "RecipientUserId", DeleteRule = "No Action")] Public EntitySet & LT; TextMessage & gt; Receive text {receive {this._TextMessages return; } Set {this._TextMessages.Assign (value); }} and for 'SenderUserId' this generates the named property for this garbage:
[Association (name = "FK__TextMessa__Sende__73852659", storage = " __ TextMessa__Sende__73852659s ", ThisKey =" Id ", Others =" Sender User ", Deleted Rules =" No Action ")] Public EntitySet & lt; TextMessage & gt; _TextMessa__Sende__73852659s {Get it {return. @__TystemA_endand__7385265 9S; } Set {this @ __textmess_send__73852659.Sysin (value); }} How can I remedy it? Is it a futile way to generate Linq to Sql code ???
It is generating names based on the foreign key. Make your foreign key more readable as compared to the auto-generated name. For example:
Handicap RecipientMessages Foreign Key (RecipientUserId) Reference ApplicationUser (UserId)
Comments
Post a Comment