Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

How to save single entity/class data to multiple table

$
0
0

so tell me how could i design whole things. suppose i have a registration class what has so many properties like

Account information
----------------------
First Name
Surname
Company Name
Contact Number
Email :
Password
Confirm Password

Billing information
----------------------
Address1
Address2
Town/City
County/State
PostCode
Billing Country

i have one customer class which has many properties for account and billing information. now i want when i will save customer data by EF then account info will be saved in customer table and billing info will be saved in address table. so tell me how could i do this mapping when i am working with EF db first and code first.

i found one relevant article link https://dukhabandhu.wordpress.com/2014/11/12/table-and-entity-splitting-in-entity-framework-code-first/

https://blogs.msdn.microsoft.com/simonince/2009/03/23/mapping-two-tables-to-one-entity-in-the-entity-framework/

i think this link is close to my requirement https://dotnetfalcon.azurewebsites.net/stackoverflow-adventures-entity-framework-code-first-advanced-mapping-scenarios/

they are showing that we must have two class having parent-child relationship then we can save to multiple table.

please discuss with a sample code. thanks


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>