entity framework - How to implement code first with existing database -
I am using EntryPremaker 5 with the first model of code and existing database. I am implementing the repository pattern. I have a BasInty class like the following: Now I have a table customer who has placed the customer key as the primary key. How should I map such farms with the ID of the BaseTinti? If I have a composite key then how should I map it to BaseIntI ID Please help me. Ensure that you initialize your dbcip to first: context.Database.Initialize (false); The first code is a good article on database initializers: Public abstract partial class basenti // & lt; Summary & gt; /// sets the entity identifier /// & lt; / summary & gt; Public virtual id id {get; Set; } Public override baul par (object obj) {return equal (obj as base entity); } Private Static Bull Introductory (BaseInty OBJ) {Comeback OBJ! = Null & amp; amp; Equal (obj.Id, default (int)); } Private Type GetUnproxiedType () {return GetType (); } Public Virtual Bull Equals (BaseInt Other) {If (other == blank) returned false; If (context aquas (this, others)) comes back true; If (! Intentient (this) & amp ;! Elegantien (Other) & IQ (ID, Other ID)) {var Other Type = Other GetUnPCide Type (); Var thisType = GetUnproxiedType (); Come back like this. EssentialFlom (other type) || OtherType.IsAssignableFrom (thisType); } return false; } Public Override Intoshashcode () {if (Eulles (ID, Default) return base. GetHashCode (); Return id GetHashCode (); } Public Stable Bull Operator == (BaseTenti X, BaseIntyY) {return equal (X, Y); } Public Stable Bull Operator! = (BASINTY X, BASINTY Y) {Return! (X == y); } Protected Virtual Wide Setpend (Dynamic Child) {} Protected Virtual Void Setpension (dynamic child) {} Safe Wired Hair Collection Soft & lt; T & gt; (Icicle & lt; T & gt; Collections, Iconsion & lt; T & gt; newCollection) where T: class {if (CommonHelper.OneToManyCollectionWrapperEnabled) {Collection.Clear (); If (newCollection! = Null) newCollection.ToList (). ForEach (x = & gt; Add Collections (x)); } And {collection = new collection; }} Protected iconging & lt; T & gt; Hair Collection Gateter & lt; T & gt; (Ref iyrawlink & lt; T & gt; archive, referee iacolink & lt; T & gt; wrapped compilation) where T: class {returning hair collection gear (referee collection, referee lipid collection, setpaper, setpenttalol); } Protected iconging & lt; T & gt; Lieutenant Greater & lt; T & gt; (Rich Ikelonac & lt; T & gt; Collection, ref Ilkonac & lt; T & gt; Lipteclip, action & lt; dynamic & gt; setpant, action & lt; dynamic & gt; setpointanton) where T: class {if ( CommonHelper.OnTamonClothWizard is enabled) (LipTextCollection = (Archive ?? (collection = new list & lt; T & gt; ()). SetupBeforeAndAfterActions (setParent, SetParentToNull); Return collection ?? (Collection = new list & lt; T & gt; ()); }}
Comments
Post a Comment