|
| 1 | +// <auto-generated /> |
| 2 | +using System; |
| 3 | +using System.Collections.Generic; |
| 4 | +using System.Reflection; |
| 5 | +using CustomerService.AppCore.Core.Entities; |
| 6 | +using Microsoft.EntityFrameworkCore; |
| 7 | +using Microsoft.EntityFrameworkCore.Metadata; |
| 8 | +using N8T.Core.Domain; |
| 9 | + |
| 10 | +#pragma warning disable 219, 612, 618 |
| 11 | +#nullable enable |
| 12 | + |
| 13 | +namespace CustomerService.Infrastructure |
| 14 | +{ |
| 15 | + partial class CreditCardEntityType |
| 16 | + { |
| 17 | + public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType? baseEntityType = null) |
| 18 | + { |
| 19 | + var runtimeEntityType = model.AddEntityType( |
| 20 | + "CustomerService.AppCore.Core.Entities.CreditCard", |
| 21 | + typeof(CreditCard), |
| 22 | + baseEntityType); |
| 23 | + |
| 24 | + var id = runtimeEntityType.AddProperty( |
| 25 | + "Id", |
| 26 | + typeof(Guid), |
| 27 | + propertyInfo: typeof(EntityBase).GetProperty("Id", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), |
| 28 | + fieldInfo: typeof(EntityBase).GetField("<Id>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), |
| 29 | + valueGenerated: ValueGenerated.OnAdd, |
| 30 | + afterSaveBehavior: PropertySaveBehavior.Throw); |
| 31 | + id.AddAnnotation("Relational:ColumnName", "id"); |
| 32 | + id.AddAnnotation("Relational:ColumnType", "uuid"); |
| 33 | + id.AddAnnotation("Relational:DefaultValueSql", "uuid_generate_v4()"); |
| 34 | + |
| 35 | + var active = runtimeEntityType.AddProperty( |
| 36 | + "Active", |
| 37 | + typeof(bool), |
| 38 | + propertyInfo: typeof(CreditCard).GetProperty("Active", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), |
| 39 | + fieldInfo: typeof(CreditCard).GetField("<Active>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)); |
| 40 | + active.AddAnnotation("Relational:ColumnName", "active"); |
| 41 | + |
| 42 | + var cardNumber = runtimeEntityType.AddProperty( |
| 43 | + "CardNumber", |
| 44 | + typeof(string), |
| 45 | + propertyInfo: typeof(CreditCard).GetProperty("CardNumber", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), |
| 46 | + fieldInfo: typeof(CreditCard).GetField("<CardNumber>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), |
| 47 | + maxLength: 16); |
| 48 | + cardNumber.AddAnnotation("Relational:ColumnName", "card_number"); |
| 49 | + |
| 50 | + var created = runtimeEntityType.AddProperty( |
| 51 | + "Created", |
| 52 | + typeof(DateTime), |
| 53 | + propertyInfo: typeof(EntityBase).GetProperty("Created", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), |
| 54 | + fieldInfo: typeof(EntityBase).GetField("<Created>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), |
| 55 | + valueGenerated: ValueGenerated.OnAdd); |
| 56 | + created.AddAnnotation("Relational:ColumnName", "created"); |
| 57 | + created.AddAnnotation("Relational:DefaultValueSql", "now()"); |
| 58 | + |
| 59 | + var customerId = runtimeEntityType.AddProperty( |
| 60 | + "CustomerId", |
| 61 | + typeof(Guid)); |
| 62 | + customerId.AddAnnotation("Relational:ColumnName", "customer_id"); |
| 63 | + |
| 64 | + var expiry = runtimeEntityType.AddProperty( |
| 65 | + "Expiry", |
| 66 | + typeof(DateTime), |
| 67 | + propertyInfo: typeof(CreditCard).GetProperty("Expiry", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), |
| 68 | + fieldInfo: typeof(CreditCard).GetField("<Expiry>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)); |
| 69 | + expiry.AddAnnotation("Relational:ColumnName", "expiry"); |
| 70 | + |
| 71 | + var nameOnCard = runtimeEntityType.AddProperty( |
| 72 | + "NameOnCard", |
| 73 | + typeof(string), |
| 74 | + propertyInfo: typeof(CreditCard).GetProperty("NameOnCard", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), |
| 75 | + fieldInfo: typeof(CreditCard).GetField("<NameOnCard>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), |
| 76 | + maxLength: 20); |
| 77 | + nameOnCard.AddAnnotation("Relational:ColumnName", "name_on_card"); |
| 78 | + |
| 79 | + var updated = runtimeEntityType.AddProperty( |
| 80 | + "Updated", |
| 81 | + typeof(DateTime?), |
| 82 | + propertyInfo: typeof(EntityBase).GetProperty("Updated", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), |
| 83 | + fieldInfo: typeof(EntityBase).GetField("<Updated>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), |
| 84 | + nullable: true); |
| 85 | + updated.AddAnnotation("Relational:ColumnName", "updated"); |
| 86 | + |
| 87 | + var key = runtimeEntityType.AddKey( |
| 88 | + new[] { id }); |
| 89 | + runtimeEntityType.SetPrimaryKey(key); |
| 90 | + key.AddAnnotation("Relational:Name", "pk_credit_cards"); |
| 91 | + |
| 92 | + var index = runtimeEntityType.AddIndex( |
| 93 | + new[] { customerId }); |
| 94 | + index.AddAnnotation("Relational:Name", "ix_credit_cards_customer_id"); |
| 95 | + |
| 96 | + var index0 = runtimeEntityType.AddIndex( |
| 97 | + new[] { id }, |
| 98 | + unique: true); |
| 99 | + index0.AddAnnotation("Relational:Name", "ix_credit_cards_id"); |
| 100 | + |
| 101 | + return runtimeEntityType; |
| 102 | + } |
| 103 | + |
| 104 | + public static RuntimeForeignKey CreateForeignKey1(RuntimeEntityType declaringEntityType, RuntimeEntityType principalEntityType) |
| 105 | + { |
| 106 | + var runtimeForeignKey = declaringEntityType.AddForeignKey(new[] { declaringEntityType.FindProperty("CustomerId")! }, |
| 107 | + principalEntityType.FindKey(new[] { principalEntityType.FindProperty("Id")! })!, |
| 108 | + principalEntityType, |
| 109 | + deleteBehavior: DeleteBehavior.Cascade, |
| 110 | + required: true); |
| 111 | + |
| 112 | + var customer = declaringEntityType.AddNavigation("Customer", |
| 113 | + runtimeForeignKey, |
| 114 | + onDependent: true, |
| 115 | + typeof(Customer), |
| 116 | + propertyInfo: typeof(CreditCard).GetProperty("Customer", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), |
| 117 | + fieldInfo: typeof(CreditCard).GetField("<Customer>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)); |
| 118 | + |
| 119 | + var creditCards = principalEntityType.AddNavigation("CreditCards", |
| 120 | + runtimeForeignKey, |
| 121 | + onDependent: false, |
| 122 | + typeof(IEnumerable<CreditCard>), |
| 123 | + propertyInfo: typeof(Customer).GetProperty("CreditCards", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), |
| 124 | + fieldInfo: typeof(Customer).GetField("_creditCards", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)); |
| 125 | + |
| 126 | + runtimeForeignKey.AddAnnotation("Relational:Name", "fk_credit_cards_customers_customer_id"); |
| 127 | + return runtimeForeignKey; |
| 128 | + } |
| 129 | + |
| 130 | + public static void CreateAnnotations(RuntimeEntityType runtimeEntityType) |
| 131 | + { |
| 132 | + runtimeEntityType.AddAnnotation("Relational:FunctionName", null); |
| 133 | + runtimeEntityType.AddAnnotation("Relational:Schema", "customer"); |
| 134 | + runtimeEntityType.AddAnnotation("Relational:SqlQuery", null); |
| 135 | + runtimeEntityType.AddAnnotation("Relational:TableName", "credit_cards"); |
| 136 | + runtimeEntityType.AddAnnotation("Relational:ViewName", null); |
| 137 | + runtimeEntityType.AddAnnotation("Relational:ViewSchema", null); |
| 138 | + |
| 139 | + Customize(runtimeEntityType); |
| 140 | + } |
| 141 | + |
| 142 | + static partial void Customize(RuntimeEntityType runtimeEntityType); |
| 143 | + } |
| 144 | +} |
0 commit comments