c# - Complex type inside Database-first model of a DDD project -


In my EF6 project [database-first approach] I say that I have a complex type called address .

[There is no identity just to clarify my complex type and is only merged with the collection of standalone data and it is not responsible for its persistence]

Currently All the fields associated with the address I have are the following for the individual parts of the address as the direct attributes of the address and the following is the automatically defined definition for the individual category:

  public class person {public Ent ID (Receive); Set; } Public string name {get; Set; } Public taps qualified & lt; Int & gt; Eating {Received; Set; } Public taps qualified & lt; Int & gt; Reply {receive; Set; } Public string building {get; Set; } Receive Public String County { Set; } Public string PostCode {get; Set; } Public string streetName {get; Set; } Receive public string street number { Set; } Public String Town {get; Set; } Receive public string unit { Set; } Get public string grams { Set; } Receive public int country ID {}; Set; }}  

Ideally I would like to do something like the following [every time I update the model from the database]:

  Public Entry ID {Received; Set; } Public string name {get; Set; } Public Address Address {get; Set; }} Public Category Address {Public Taps Affordable & lt; Int & gt; Eating {Received; Set; } Public taps qualified & lt; Int & gt; Reply {receive; Set; } Public string building {get; Set; } Receive Public String County { Set; } Public string PostCode {get; Set; } Public string streetName {get; Set; } Receive public string street number { Set; } Public String Town {get; Set; } Receive public string unit { Set; } Get public string grams { Set; } Receive public int country ID {}; Set; }}  

When I update my model from database (SQL Server 2012), how can I tell address fields as an aggregate field?

As far as I know the only way forward is modifying the T4 template. If your only suggested solution is the T4 template alternation, can you please show me some sample projects that are taking similar tactics or providing your own version.

When you use the database for the first time in EF, all responsibilities for the resulting class on the generator Holds. So you can not find the complex type of address in this approach. You should use other methods to achieve what you want. If I were you, then I am using the code first approach and I will write mapping in classes in the code from the existing database.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -