diff --git a/changelog.txt b/changelog.txt index f75377f1c..b5b952388 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ 3.0.4 - Added context menu choice to visually align node elements on diagrams. + - Fix to detecting correct EF version with anything with "Latest" in it is configured (see https://github.com/msawczyn/EFDesigner/issues/266) + - Fix to generate correct initial value code for decimal properties (see https://github.com/msawczyn/EFDesigner/issues/268) + - Fix for constructor code generation in 1-N unidirectional associations (see https://github.com/msawczyn/EFDesigner/issues/263) 3.0.3 - Added VS UML icon for model file in solution explorer (thanks to https://github.com/dcastenholz for the change) diff --git a/dist/Sawczyn.EFDesigner.EFModel.DslPackage.vsix b/dist/Sawczyn.EFDesigner.EFModel.DslPackage.vsix index 40ed26696..27e1b0ce4 100644 Binary files a/dist/Sawczyn.EFDesigner.EFModel.DslPackage.vsix and b/dist/Sawczyn.EFDesigner.EFModel.DslPackage.vsix differ diff --git a/src/Dsl/CustomCode/Partials/Association.cs b/src/Dsl/CustomCode/Partials/Association.cs index 7455b3480..40715b4ed 100644 --- a/src/Dsl/CustomCode/Partials/Association.cs +++ b/src/Dsl/CustomCode/Partials/Association.cs @@ -243,8 +243,8 @@ internal bool AllCardinalitiesAreValid(out string errorMessage) } [ValidationMethod(ValidationCategories.Save | ValidationCategories.Menu)] - [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validatioin")] - // ReSharper disable once UnusedMember.Local + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void ValidateMultiplicity(ValidationContext context) { if (!AllCardinalitiesAreValid(out string errorMessage)) @@ -252,8 +252,8 @@ private void ValidateMultiplicity(ValidationContext context) } [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)] - // ReSharper disable once UnusedMember.Local - [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validatioin")] + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void SummaryDescriptionIsEmpty(ValidationContext context) { if (Source?.ModelRoot == null) return; @@ -268,8 +268,8 @@ private void SummaryDescriptionIsEmpty(ValidationContext context) } [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)] - // ReSharper disable once UnusedMember.Local - [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validatioin")] + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void TPCEndpointsOnlyOnLeafNodes(ValidationContext context) { if (Source?.ModelRoot == null) return; @@ -282,7 +282,7 @@ private void TPCEndpointsOnlyOnLeafNodes(ValidationContext context) [ValidationMethod(ValidationCategories.Save | ValidationCategories.Load | ValidationCategories.Menu)] [UsedImplicitly] - [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validatioin")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void MustDetermineEndpointRoles(ValidationContext context) { if (Source?.ModelRoot == null) @@ -298,7 +298,7 @@ private void MustDetermineEndpointRoles(ValidationContext context) [ValidationMethod(ValidationCategories.Save | ValidationCategories.Load | ValidationCategories.Menu)] [UsedImplicitly] - [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validatioin")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void FKPropertiesCannotBeStoreGeneratedIdentifiers(ValidationContext context) { @@ -338,6 +338,7 @@ string GetShadowPropertyName(string nameBase) if (SourceRole == EndpointRole.Dependent) return $"{nameBase}{identityAttribute.Name}"; + // ReSharper disable once ConvertIfStatementToReturnStatement if (this is BidirectionalAssociation) return $"{nameBase}{identityAttribute.Name}"; @@ -362,7 +363,8 @@ string GetShadowPropertyNameBase() } [ValidationMethod(ValidationCategories.Save | ValidationCategories.Load | ValidationCategories.Menu)] - [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validatioin")] + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void FKPropertiesInvalidWithoutDependentEnd(ValidationContext context) { if (string.IsNullOrWhiteSpace(FKPropertyName)) @@ -377,7 +379,8 @@ private void FKPropertiesInvalidWithoutDependentEnd(ValidationContext context) } [ValidationMethod(ValidationCategories.Save | ValidationCategories.Load | ValidationCategories.Menu)] - [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validatioin")] + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void FKPropertiesMatchIdentityProperties(ValidationContext context) { if (string.IsNullOrWhiteSpace(FKPropertyName) || Principal == null) diff --git a/src/Dsl/CustomCode/Partials/BidirectionalAssociation.cs b/src/Dsl/CustomCode/Partials/BidirectionalAssociation.cs index d5211c0ce..ab76c97b5 100644 --- a/src/Dsl/CustomCode/Partials/BidirectionalAssociation.cs +++ b/src/Dsl/CustomCode/Partials/BidirectionalAssociation.cs @@ -4,6 +4,7 @@ using Microsoft.VisualStudio.Modeling; using Microsoft.VisualStudio.Modeling.Validation; +using Sawczyn.EFDesigner.EFModel.Annotations; using Sawczyn.EFDesigner.EFModel.Extensions; namespace Sawczyn.EFDesigner.EFModel @@ -19,8 +20,8 @@ private string GetSourcePropertyNameDisplayValue() } [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)] - // ReSharper disable once UnusedMember.Local - [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validatioin")] + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void SummaryDescriptionIsEmpty(ValidationContext context) { if (Source?.ModelRoot == null) return; diff --git a/src/Dsl/CustomCode/Partials/ModelAttribute.cs b/src/Dsl/CustomCode/Partials/ModelAttribute.cs index e0d7cc167..e95ed862e 100644 --- a/src/Dsl/CustomCode/Partials/ModelAttribute.cs +++ b/src/Dsl/CustomCode/Partials/ModelAttribute.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using Microsoft.VisualStudio.Modeling; @@ -13,7 +12,7 @@ namespace Sawczyn.EFDesigner.EFModel { [ValidationState(ValidationState.Enabled)] - [SuppressMessage("ReSharper", "ArrangeAccessorOwnerBody")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ArrangeAccessorOwnerBody")] public partial class ModelAttribute : IModelElementInCompartment, IDisplaysWarning, IHasStore { internal const int MAXLENGTH_MAX = -1; @@ -116,8 +115,6 @@ public bool SupportsInitialValue /// Name of type to test. If typeName is null, Type property will be used. If initialValue is null, InitialValue property will be used /// Initial value to test /// true if InitialValue is a valid value for the type, or if initialValue is null or empty -#pragma warning disable 168 - [SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")] public bool IsValidInitialValue(string typeName = null, string initialValue = null) { typeName = typeName ?? Type; @@ -154,9 +151,9 @@ public bool IsValidInitialValue(string typeName = null, string initialValue = nu case "Polygon": return false; //string.IsNullOrEmpty(initialValue); case "Boolean": - return bool.TryParse(initialValue, out bool _bool); + return bool.TryParse(initialValue, out _); case "Byte": - return byte.TryParse(initialValue, out byte _byte); + return byte.TryParse(initialValue, out _); case "DateTime": switch (initialValue?.Trim()) { @@ -166,32 +163,32 @@ public bool IsValidInitialValue(string typeName = null, string initialValue = nu case "DateTime.MaxValue": return true; default: - return DateTime.TryParse(initialValue, out DateTime _dateTime); + return DateTime.TryParse(initialValue, out _); } case "DateTimeOffset": - return DateTimeOffset.TryParse(initialValue, out DateTimeOffset _dateTimeOffset); + return DateTimeOffset.TryParse(initialValue, out _); case "Decimal": - return Decimal.TryParse(initialValue, out Decimal _decimal); + return Decimal.TryParse(initialValue, out _); case "Double": - return Double.TryParse(initialValue, out Double _double); + return Double.TryParse(initialValue, out _); case "Guid": - return Guid.TryParse(initialValue, out Guid _guid); + return Guid.TryParse(initialValue, out _); case "Int16": - return Int16.TryParse(initialValue, out Int16 _int16); + return Int16.TryParse(initialValue, out _); case "UInt16": - return UInt16.TryParse(initialValue, out UInt16 _uint16); + return UInt16.TryParse(initialValue, out _); case "Int32": - return Int32.TryParse(initialValue, out Int32 _int32); + return Int32.TryParse(initialValue, out _); case "UInt32": - return UInt32.TryParse(initialValue, out UInt32 _uint32); + return UInt32.TryParse(initialValue, out _); case "Int64": - return Int64.TryParse(initialValue, out Int64 _int64); + return Int64.TryParse(initialValue, out _); case "UInt64": - return UInt64.TryParse(initialValue, out UInt64 _uint64); + return UInt64.TryParse(initialValue, out _); case "SByte": - return SByte.TryParse(initialValue, out SByte _sbyte); + return SByte.TryParse(initialValue, out _); case "Single": - return Single.TryParse(initialValue, out Single _single); + return Single.TryParse(initialValue, out _); case "String": return true; case "Time": @@ -199,8 +196,7 @@ public bool IsValidInitialValue(string typeName = null, string initialValue = nu new[] { "HH:mm:ss", "H:mm:ss", "HH:mm", "H:mm", "HH:mm:ss tt", "H:mm:ss tt", "HH:mm tt", "H:mm tt" }, CultureInfo.InvariantCulture, DateTimeStyles.None, - out DateTime _time); - // ReSharper restore UnusedVariable + out _); default: if (initialValue.Contains(".")) { @@ -214,7 +210,6 @@ public bool IsValidInitialValue(string typeName = null, string initialValue = nu return false; } -#pragma warning restore 168 /// /// From internal class System.Data.Metadata.Edm.PrimitiveType in System.Data.Entity. Converts the attribute's CLR type to a C# primitive type. @@ -935,6 +930,7 @@ internal static (string ef6Version, string efCoreVersion)[] GeometryTypes = { [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)] [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void GeographyTypeDoesNotMatchEFVersion(ValidationContext context) { if (ModelClass?.ModelRoot == null) return; @@ -966,7 +962,8 @@ private void GeographyTypeDoesNotMatchEFVersion(ValidationContext context) } [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)] - // ReSharper disable once UnusedMember.Local + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void StringsShouldHaveLength(ValidationContext context) { if (ModelClass?.ModelRoot == null) return; @@ -980,7 +977,8 @@ private void StringsShouldHaveLength(ValidationContext context) } [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)] - // ReSharper disable once UnusedMember.Local + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void SummaryDescriptionIsEmpty(ValidationContext context) { if (ModelClass?.ModelRoot == null) return; diff --git a/src/Dsl/CustomCode/Partials/ModelClass.cs b/src/Dsl/CustomCode/Partials/ModelClass.cs index ca7e1528c..7d3214511 100644 --- a/src/Dsl/CustomCode/Partials/ModelClass.cs +++ b/src/Dsl/CustomCode/Partials/ModelClass.cs @@ -6,6 +6,7 @@ using Microsoft.VisualStudio.Modeling; using Microsoft.VisualStudio.Modeling.Validation; +using Sawczyn.EFDesigner.EFModel.Annotations; using Sawczyn.EFDesigner.EFModel.Extensions; // ReSharper disable UnusedMember.Global @@ -493,6 +494,8 @@ internal void MoveAttribute(ModelAttribute attribute, ModelClass destination) #region Validations [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)] + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void ClassShouldHaveAttributes(ValidationContext context) { if (ModelRoot == null) return; @@ -506,6 +509,8 @@ private void ClassShouldHaveAttributes(ValidationContext context) } [ValidationMethod(ValidationCategories.Open | ValidationCategories.Menu)] + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void OwnedTypeCannotHaveABaseClass(ValidationContext context) { if (ModelRoot == null) return; @@ -514,6 +519,8 @@ private void OwnedTypeCannotHaveABaseClass(ValidationContext context) } [ValidationMethod(ValidationCategories.Open | ValidationCategories.Menu)] + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void OwnedTypeCannotHaveASubclass(ValidationContext context) { if (ModelRoot == null) return; @@ -522,6 +529,8 @@ private void OwnedTypeCannotHaveASubclass(ValidationContext context) } [ValidationMethod(ValidationCategories.Open | ValidationCategories.Menu)] + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void OwnedTypeCannotBeAbstract(ValidationContext context) { if (ModelRoot == null) return; @@ -530,6 +539,8 @@ private void OwnedTypeCannotBeAbstract(ValidationContext context) } [ValidationMethod(ValidationCategories.Open | ValidationCategories.Menu)] + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void OwnedTypeCannotBePrincipal(ValidationContext context) { if (ModelRoot == null) return; @@ -544,6 +555,8 @@ private void OwnedTypeCannotBePrincipal(ValidationContext context) } [ValidationMethod(ValidationCategories.Open | ValidationCategories.Menu)] + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void OwnedTypeCannotBeInBidirectionalAssociation(ValidationContext context) { if (ModelRoot == null) return; @@ -553,6 +566,8 @@ private void OwnedTypeCannotBeInBidirectionalAssociation(ValidationContext conte } [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)] + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void AttributesCannotBeNamedSameAsEnclosingClass(ValidationContext context) { if (ModelRoot == null) return; @@ -562,6 +577,8 @@ private void AttributesCannotBeNamedSameAsEnclosingClass(ValidationContext conte } [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)] + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void PersistentClassesMustHaveIdentity(ValidationContext context) { if (ModelRoot == null) return; @@ -571,6 +588,8 @@ private void PersistentClassesMustHaveIdentity(ValidationContext context) } [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)] + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void DerivedClassesShouldNotHaveIdentity(ValidationContext context) { if (ModelRoot == null) return; @@ -594,6 +613,8 @@ private void DerivedClassesShouldNotHaveIdentity(ValidationContext context) } [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)] + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void SummaryDescriptionIsEmpty(ValidationContext context) { if (ModelRoot == null) return; diff --git a/src/Dsl/CustomCode/Partials/ModelEnum.cs b/src/Dsl/CustomCode/Partials/ModelEnum.cs index 166af2db2..53193cfc9 100644 --- a/src/Dsl/CustomCode/Partials/ModelEnum.cs +++ b/src/Dsl/CustomCode/Partials/ModelEnum.cs @@ -6,6 +6,7 @@ using System.ComponentModel; using System.Linq; +using Sawczyn.EFDesigner.EFModel.Annotations; using Sawczyn.EFDesigner.EFModel.Extensions; namespace Sawczyn.EFDesigner.EFModel @@ -189,7 +190,8 @@ internal virtual void ResetIsTrackingProperties() } [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)] - // ReSharper disable once UnusedMember.Local + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void EnumMustHaveValues(ValidationContext context) { if (ModelRoot == null) return; @@ -199,7 +201,8 @@ private void EnumMustHaveValues(ValidationContext context) } [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)] - // ReSharper disable once UnusedMember.Local + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void EnumValueInitializationsShouldBeAllOrNothing(ValidationContext context) { if (ModelRoot == null) return; @@ -213,7 +216,8 @@ private void EnumValueInitializationsShouldBeAllOrNothing(ValidationContext cont } [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)] - // ReSharper disable once UnusedMember.Local + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void SummaryDescriptionIsEmpty(ValidationContext context) { if (ModelRoot == null) return; diff --git a/src/Dsl/CustomCode/Partials/ModelEnumValue.cs b/src/Dsl/CustomCode/Partials/ModelEnumValue.cs index 0e718f4eb..0c6373499 100644 --- a/src/Dsl/CustomCode/Partials/ModelEnumValue.cs +++ b/src/Dsl/CustomCode/Partials/ModelEnumValue.cs @@ -2,9 +2,10 @@ using Microsoft.VisualStudio.Modeling.Diagrams; using Microsoft.VisualStudio.Modeling.Validation; using Sawczyn.EFDesigner.EFModel.Extensions; -using System.Collections.Generic; using System.Linq; +using Sawczyn.EFDesigner.EFModel.Annotations; + namespace Sawczyn.EFDesigner.EFModel { [ValidationState(ValidationState.Enabled)] @@ -41,7 +42,8 @@ public void RedrawItem() #endregion [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)] - // ReSharper disable once UnusedMember.Local + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void SummaryDescriptionIsEmpty(ValidationContext context) { if (Enum?.ModelRoot == null) return; diff --git a/src/Dsl/CustomCode/Partials/ModelRoot.cs b/src/Dsl/CustomCode/Partials/ModelRoot.cs index 8685fd9aa..a85fa6bf4 100644 --- a/src/Dsl/CustomCode/Partials/ModelRoot.cs +++ b/src/Dsl/CustomCode/Partials/ModelRoot.cs @@ -9,6 +9,7 @@ using Microsoft.VisualStudio.Modeling.Diagrams; using Microsoft.VisualStudio.Modeling.Validation; +using Sawczyn.EFDesigner.EFModel.Annotations; using Sawczyn.EFDesigner.EFModel.Extensions; namespace Sawczyn.EFDesigner.EFModel @@ -290,40 +291,73 @@ public bool IsValidCLRType(string type) #region Nuget + [Obsolete] public NuGetDisplay NuGetPackageVersion { get { return NuGetHelper.NuGetPackageDisplay - .FirstOrDefault(x => x.EFVersion == EntityFrameworkVersion + .FirstOrDefault(x => x.EFVersion == EntityFrameworkVersion && x.DisplayVersion == EntityFrameworkPackageVersion); } } + /// + /// Transforms the selected EntityFrameworkPackageVersion into a decimal number, only taking the first two segments into account. If a "Latest" version is chosen, looks up the appropriate real version. + /// public double GetEntityFrameworkPackageVersionNum() { string packageVersion = EntityFrameworkPackageVersion; + string[] parts = packageVersion.Split('.'); if (packageVersion.EndsWith("Latest")) - packageVersion = NuGetHelper.EFPackageVersions[EntityFrameworkVersion].Where(x => !x.EndsWith("Latest")).OrderByDescending(x => x).FirstOrDefault(); + { + (int A, int B, int C) actualVersion; - string[] parts = (packageVersion ?? "").Split('.'); + switch (parts.Length) + { + case 1: // just "Latest" + actualVersion = NugetVersions.Last(); + break; + case 2: // x.Latest + actualVersion = NugetVersions.Last(v => v.A == int.Parse(parts[0])); + break; + default: // x.y.Latest + actualVersion = NugetVersions.Last(v => v.A == int.Parse(parts[0]) && v.B == int.Parse(parts[1])); + break; + } - string resultString = parts.Length > 1 - ? $"{parts[0]}.{parts[1]}" - : parts.FirstOrDefault(); + packageVersion = $"{actualVersion.A}.{actualVersion.B}"; + } + else + packageVersion = $"{parts[0]}.{parts[1]}"; - return double.TryParse(resultString, out double result) - ? result - : 0; + return double.Parse(packageVersion); } + private List<(int A, int B, int C)> nugetVersions; + private List<(int A, int B, int C)> NugetVersions + { + get + { + return nugetVersions + ?? (nugetVersions = NuGetHelper.EFPackageVersions[EntityFrameworkVersion] + .Where(x => x.Count(c => c == '.') == 2) + .Select(v => (int.TryParse(v.Substring(0, v.IndexOf('.')), out int x1) ? x1 : 0 + , int.TryParse(v.Substring(v.IndexOf('.') + 1, v.IndexOf('.', v.IndexOf('.') + 1) - v.IndexOf('.') - 1), out int x2) ? x2 : 0 + , int.TryParse(v.Substring(v.IndexOf('.', v.IndexOf('.') + 1) + 1), out int x3) ? x3 : 0)) + .OrderBy<(int A, int B, int C), int>(v => v.A).ThenBy(v => v.B).ThenBy(v => v.C) + .Distinct() + .ToList()); + } + } #endregion Nuget #region Validation methods [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)] - [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validatioin")] + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void ConnectionStringMustExist(ValidationContext context) { if (!Classes.Any() && !Enums.Any()) @@ -337,7 +371,8 @@ private void ConnectionStringMustExist(ValidationContext context) } [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)] - [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validatioin")] + [UsedImplicitly] + [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")] private void SummaryDescriptionIsEmpty(ValidationContext context) { if (string.IsNullOrWhiteSpace(Summary) && WarnOnMissingDocumentation) diff --git a/src/Dsl/DslDefinition.dsl b/src/Dsl/DslDefinition.dsl index c75f0b77c..d30e18fd4 100644 --- a/src/Dsl/DslDefinition.dsl +++ b/src/Dsl/DslDefinition.dsl @@ -1,5 +1,5 @@  - + diff --git a/src/Dsl/GeneratedCode/DomainClasses.cs b/src/Dsl/GeneratedCode/DomainClasses.cs index a3db16715..d452049de 100644 --- a/src/Dsl/GeneratedCode/DomainClasses.cs +++ b/src/Dsl/GeneratedCode/DomainClasses.cs @@ -13432,6 +13432,6 @@ namespace Sawczyn.EFDesigner.EFModel /// partial class ModelRoot { - public const string DSLVersion = "3.0.4.4"; + public const string DSLVersion = "3.0.4.5"; } } diff --git a/src/Dsl/GeneratedCode/SerializationHelper.cs b/src/Dsl/GeneratedCode/SerializationHelper.cs index 6e78785a7..8b5c99cc6 100644 --- a/src/Dsl/GeneratedCode/SerializationHelper.cs +++ b/src/Dsl/GeneratedCode/SerializationHelper.cs @@ -1168,7 +1168,7 @@ public virtual void WriteRootElement(DslModeling::SerializationContext serializa // Only model has schema, diagram has no schema. rootElementSettings.SchemaTargetNamespace = "http://schemas.microsoft.com/dsltools/EFModel"; } - rootElementSettings.Version = new global::System.Version("3.0.4.4"); + rootElementSettings.Version = new global::System.Version("3.0.4.5"); // Carry out the normal serialization. rootSerializer.Write(serializationContext, rootElement, writer, rootElementSettings); @@ -1190,7 +1190,7 @@ protected virtual void CheckVersion(DslModeling::SerializationContext serializat throw new global::System.ArgumentNullException("reader"); #endregion - global::System.Version expectedVersion = new global::System.Version("3.0.4.4"); + global::System.Version expectedVersion = new global::System.Version("3.0.4.5"); string dslVersionStr = reader.GetAttribute("dslVersion"); if (dslVersionStr != null) { diff --git a/src/DslPackage/DslPackage.csproj b/src/DslPackage/DslPackage.csproj index 84119664f..e5aaa58b3 100644 --- a/src/DslPackage/DslPackage.csproj +++ b/src/DslPackage/DslPackage.csproj @@ -244,6 +244,18 @@ true + + + + + + + + + + + + VsctGenerator @@ -395,6 +407,7 @@ true + diff --git a/src/DslPackage/GeneratedCode/Constants.cs b/src/DslPackage/GeneratedCode/Constants.cs index b2ee940ca..455f30012 100644 --- a/src/DslPackage/GeneratedCode/Constants.cs +++ b/src/DslPackage/GeneratedCode/Constants.cs @@ -18,7 +18,7 @@ internal static partial class Constants [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] public const string CompanyName = @"Michael Sawczyn"; [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] - public const string ProductVersion = "3.0.4.4"; + public const string ProductVersion = "3.0.4.5"; // Menu definitions public static readonly global::System.ComponentModel.Design.CommandID EFModelDiagramMenu = new global::System.ComponentModel.Design.CommandID(new global::System.Guid(EFModelCommandSetId), 0x10000); diff --git a/src/DslPackage/Parsers/EF6Parser.exe b/src/DslPackage/Parsers/EF6Parser.exe index 7c761de3a..930eb5c2c 100644 Binary files a/src/DslPackage/Parsers/EF6Parser.exe and b/src/DslPackage/Parsers/EF6Parser.exe differ diff --git a/src/DslPackage/Parsers/EFCore2Parser.exe b/src/DslPackage/Parsers/EFCore2Parser.exe index 8f4db0d1e..585fe18db 100644 Binary files a/src/DslPackage/Parsers/EFCore2Parser.exe and b/src/DslPackage/Parsers/EFCore2Parser.exe differ diff --git a/src/DslPackage/Parsers/EFCore3Parser.exe b/src/DslPackage/Parsers/EFCore3Parser.exe index 75aa9f475..c8ae07298 100644 Binary files a/src/DslPackage/Parsers/EFCore3Parser.exe and b/src/DslPackage/Parsers/EFCore3Parser.exe differ diff --git a/src/DslPackage/Parsers/EFCore5Parser.exe b/src/DslPackage/Parsers/EFCore5Parser.exe index 5654a0991..f9bc3ee3c 100644 Binary files a/src/DslPackage/Parsers/EFCore5Parser.exe and b/src/DslPackage/Parsers/EFCore5Parser.exe differ diff --git a/src/DslPackage/TextTemplates/EF6Designer.ttinclude b/src/DslPackage/TextTemplates/EF6Designer.ttinclude index d1212998f..a1e1e070a 100644 --- a/src/DslPackage/TextTemplates/EF6Designer.ttinclude +++ b/src/DslPackage/TextTemplates/EF6Designer.ttinclude @@ -23,7 +23,7 @@ #><#@ import namespace="System.Data.Entity.Design.PluralizationServices" #><#@ import namespace="Microsoft.VisualStudio.TextTemplating" #><#+ -// EFDesigner v3.0.3 +// EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/EF6ModelGenerator.ttinclude b/src/DslPackage/TextTemplates/EF6ModelGenerator.ttinclude index e099b443e..cd7f402fe 100644 --- a/src/DslPackage/TextTemplates/EF6ModelGenerator.ttinclude +++ b/src/DslPackage/TextTemplates/EF6ModelGenerator.ttinclude @@ -23,7 +23,7 @@ #><#@ import namespace="System.Data.Entity.Design.PluralizationServices" #><#@ import namespace="Microsoft.VisualStudio.TextTemplating" #><#+ - // EFDesigner v3.0.3 + // EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/EFCore2ModelGenerator.ttinclude b/src/DslPackage/TextTemplates/EFCore2ModelGenerator.ttinclude index fc1e16a82..fd52c6838 100644 --- a/src/DslPackage/TextTemplates/EFCore2ModelGenerator.ttinclude +++ b/src/DslPackage/TextTemplates/EFCore2ModelGenerator.ttinclude @@ -23,7 +23,7 @@ #><#@ import namespace="System.Data.Entity.Design.PluralizationServices" #><#@ import namespace="Microsoft.VisualStudio.TextTemplating" #><#+ - // EFDesigner v3.0.3 + // EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/EFCore3ModelGenerator.ttinclude b/src/DslPackage/TextTemplates/EFCore3ModelGenerator.ttinclude index 79c81a265..7eb341198 100644 --- a/src/DslPackage/TextTemplates/EFCore3ModelGenerator.ttinclude +++ b/src/DslPackage/TextTemplates/EFCore3ModelGenerator.ttinclude @@ -23,7 +23,7 @@ #><#@ import namespace="System.Data.Entity.Design.PluralizationServices" #><#@ import namespace="Microsoft.VisualStudio.TextTemplating" #><#+ - // EFDesigner v3.0.3 + // EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/EFCore5ModelGenerator.ttinclude b/src/DslPackage/TextTemplates/EFCore5ModelGenerator.ttinclude index 930a2f263..53342e6b6 100644 --- a/src/DslPackage/TextTemplates/EFCore5ModelGenerator.ttinclude +++ b/src/DslPackage/TextTemplates/EFCore5ModelGenerator.ttinclude @@ -23,7 +23,7 @@ #><#@ import namespace="System.Data.Entity.Design.PluralizationServices" #><#@ import namespace="Microsoft.VisualStudio.TextTemplating" #><#+ - // EFDesigner v3.0.3 + // EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner @@ -63,8 +63,8 @@ { string enumName = modelAttribute.InitialValue.Split('.').First(); string enumValue = modelAttribute.InitialValue.Split('.').Last(); - string enumFQN = modelAttribute.ModelClass.ModelRoot.Enums.FirstOrDefault(e => e.Name == enumName).FullName; - segments.Add($"HasDefaultValue({enumFQN}.{enumValue.Trim()})"); + string enumFQN = modelAttribute.ModelClass.ModelRoot.Enums.FirstOrDefault(e => e.Name == enumName)?.FullName ?? enumName; + segments.Add($"HasDefaultValue({enumFQN.Trim()}.{enumValue.Trim()})"); } else { diff --git a/src/DslPackage/TextTemplates/EFCoreDesigner.ttinclude b/src/DslPackage/TextTemplates/EFCoreDesigner.ttinclude index d1212998f..a1e1e070a 100644 --- a/src/DslPackage/TextTemplates/EFCoreDesigner.ttinclude +++ b/src/DslPackage/TextTemplates/EFCoreDesigner.ttinclude @@ -23,7 +23,7 @@ #><#@ import namespace="System.Data.Entity.Design.PluralizationServices" #><#@ import namespace="Microsoft.VisualStudio.TextTemplating" #><#+ -// EFDesigner v3.0.3 +// EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/EFCoreModelGenerator.ttinclude b/src/DslPackage/TextTemplates/EFCoreModelGenerator.ttinclude index 70f0ea8fd..f290506c4 100644 --- a/src/DslPackage/TextTemplates/EFCoreModelGenerator.ttinclude +++ b/src/DslPackage/TextTemplates/EFCoreModelGenerator.ttinclude @@ -23,7 +23,7 @@ #><#@ import namespace="System.Data.Entity.Design.PluralizationServices" #><#@ import namespace="Microsoft.VisualStudio.TextTemplating" #><#+ - // EFDesigner v3.0.3 + // EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/EFDesigner.ttinclude b/src/DslPackage/TextTemplates/EFDesigner.ttinclude index b7d309267..8dd186159 100644 --- a/src/DslPackage/TextTemplates/EFDesigner.ttinclude +++ b/src/DslPackage/TextTemplates/EFDesigner.ttinclude @@ -23,7 +23,7 @@ #><#@ import namespace="System.Data.Entity.Design.PluralizationServices" #><#@ import namespace="Microsoft.VisualStudio.TextTemplating" #><#+ - // EFDesigner v3.0.3 + // EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/EFModelFileManager.ttinclude b/src/DslPackage/TextTemplates/EFModelFileManager.ttinclude index 52aca5ce4..665408e53 100644 --- a/src/DslPackage/TextTemplates/EFModelFileManager.ttinclude +++ b/src/DslPackage/TextTemplates/EFModelFileManager.ttinclude @@ -23,7 +23,7 @@ #><#@ import namespace="System.Data.Entity.Design.PluralizationServices" #><#@ import namespace="Microsoft.VisualStudio.TextTemplating" #><#+ - // EFDesigner v3.0.3 + // EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/EFModelGenerator.ttinclude b/src/DslPackage/TextTemplates/EFModelGenerator.ttinclude index a091e24b8..59fd186ef 100644 --- a/src/DslPackage/TextTemplates/EFModelGenerator.ttinclude +++ b/src/DslPackage/TextTemplates/EFModelGenerator.ttinclude @@ -23,7 +23,7 @@ #><#@ import namespace="System.Data.Entity.Design.PluralizationServices" #><#@ import namespace="Microsoft.VisualStudio.TextTemplating" #><#+ - // EFDesigner v3.0.3 + // EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner @@ -430,6 +430,9 @@ ? x.InitialValue.Trim(quote[0]) : x.InitialValue); + if (x.FQPrimitiveType == "decimal") + value += "m"; + return $"{x.FQPrimitiveType} {x.Name.ToLower()} = {quote}{value}{quote}"; })); } @@ -700,9 +703,14 @@ ? "'" : string.Empty; + string initialValue = modelAttribute.InitialValue; + + if (modelAttribute.Type == "decimal") + initialValue += "m"; + Output(quote.Length > 0 - ? $"this.{modelAttribute.Name} = {quote}{FullyQualified(modelAttribute.InitialValue.Trim(quote[0]))}{quote};" - : $"this.{modelAttribute.Name} = {quote}{FullyQualified(modelAttribute.InitialValue)}{quote};"); + ? $"this.{modelAttribute.Name} = {quote}{FullyQualified(initialValue.Trim(quote[0]))}{quote};" + : $"this.{modelAttribute.Name} = {quote}{FullyQualified(initialValue)}{quote};"); } // all required navigation properties that aren't a 1..1 relationship @@ -714,9 +722,12 @@ string parameterName = requiredNavigationProperty.PropertyName.ToLower(); Output($"if ({parameterName} == null) throw new ArgumentNullException(nameof({parameterName}));"); - Output(requiredNavigationProperty.IsCollection - ? $"{requiredNavigationProperty.PropertyName}.Add({parameterName});" - : $"this.{requiredNavigationProperty.PropertyName} = {parameterName};"); + if (!requiredNavigationProperty.ConstructorParameterOnly) + { + Output(requiredNavigationProperty.IsCollection + ? $"{requiredNavigationProperty.PropertyName}.Add({parameterName});" + : $"this.{requiredNavigationProperty.PropertyName} = {parameterName};"); + } if (!string.IsNullOrEmpty(otherSide.PropertyName)) { @@ -781,11 +792,10 @@ && x.SetterVisibility == SetterAccessModifier.Public)) Output($@"/// {string.Join(" ", GenerateCommentBody(requiredAttribute.Summary))}"); - // TODO: Add comment if available foreach (NavigationProperty requiredNavigationProperty in modelClass.AllRequiredNavigationProperties() .Where(np => np.AssociationObject.SourceMultiplicity != Sawczyn.EFDesigner.EFModel.Multiplicity.One || np.AssociationObject.TargetMultiplicity != Sawczyn.EFDesigner.EFModel.Multiplicity.One)) - Output($@"/// "); + Output($@"/// {string.Join(" ", GenerateCommentBody(requiredNavigationProperty.Summary))}"); } protected void WriteDbContextComments() @@ -820,10 +830,14 @@ : modelAttribute.Type == "Char" ? "'" : string.Empty; + string initialValue = modelAttribute.InitialValue; + + if (modelAttribute.Type == "decimal") + initialValue += "m"; Output(quote.Length == 1 - ? $"{modelAttribute.Name} = {quote}{FullyQualified(modelAttribute.InitialValue.Trim(quote[0]))}{quote};" - : $"{modelAttribute.Name} = {quote}{FullyQualified(modelAttribute.InitialValue)}{quote};"); + ? $"{modelAttribute.Name} = {quote}{FullyQualified(initialValue.Trim(quote[0]))}{quote};" + : $"{modelAttribute.Name} = {quote}{FullyQualified(initialValue)}{quote};"); ++lineCount; } @@ -1105,7 +1119,12 @@ ? "'" : string.Empty; - segments.Add($"Default value = {quote}{FullyQualified(modelAttribute.InitialValue.Trim('"'))}{quote}"); + string initialValue = modelAttribute.InitialValue; + + if (modelAttribute.Type == "decimal") + initialValue += "m"; + + segments.Add($"Default value = {quote}{FullyQualified(initialValue.Trim('"'))}{quote}"); } string nullable = IsNullable(modelAttribute) diff --git a/src/DslPackage/TextTemplates/EditingOnly/EF6Designer.cs b/src/DslPackage/TextTemplates/EditingOnly/EF6Designer.cs index 2d8db31c0..b7781e41f 100644 --- a/src/DslPackage/TextTemplates/EditingOnly/EF6Designer.cs +++ b/src/DslPackage/TextTemplates/EditingOnly/EF6Designer.cs @@ -1,5 +1,5 @@ #region Template -// EFDesigner v3.0.3 +// EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/EditingOnly/EF6ModelGenerator.cs b/src/DslPackage/TextTemplates/EditingOnly/EF6ModelGenerator.cs index 74a66b7e8..278ecc7d8 100644 --- a/src/DslPackage/TextTemplates/EditingOnly/EF6ModelGenerator.cs +++ b/src/DslPackage/TextTemplates/EditingOnly/EF6ModelGenerator.cs @@ -11,7 +11,7 @@ namespace Sawczyn.EFDesigner.EFModel.EditingOnly public partial class GeneratedTextTransformation { #region Template - // EFDesigner v3.0.3 + // EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/EditingOnly/EFCore2ModelGenerator.cs b/src/DslPackage/TextTemplates/EditingOnly/EFCore2ModelGenerator.cs index fb0587bf5..2b22c3160 100644 --- a/src/DslPackage/TextTemplates/EditingOnly/EFCore2ModelGenerator.cs +++ b/src/DslPackage/TextTemplates/EditingOnly/EFCore2ModelGenerator.cs @@ -3,7 +3,7 @@ namespace Sawczyn.EFDesigner.EFModel.EditingOnly public partial class GeneratedTextTransformation { #region Template - // EFDesigner v3.0.3 + // EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/EditingOnly/EFCore3ModelGenerator.cs b/src/DslPackage/TextTemplates/EditingOnly/EFCore3ModelGenerator.cs index 334f5e2a3..95e9e727a 100644 --- a/src/DslPackage/TextTemplates/EditingOnly/EFCore3ModelGenerator.cs +++ b/src/DslPackage/TextTemplates/EditingOnly/EFCore3ModelGenerator.cs @@ -6,7 +6,7 @@ public partial class GeneratedTextTransformation { #region Template - // EFDesigner v3.0.3 + // EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/EditingOnly/EFCore5ModelGenerator.cs b/src/DslPackage/TextTemplates/EditingOnly/EFCore5ModelGenerator.cs index e20022be8..4e528a0ab 100644 --- a/src/DslPackage/TextTemplates/EditingOnly/EFCore5ModelGenerator.cs +++ b/src/DslPackage/TextTemplates/EditingOnly/EFCore5ModelGenerator.cs @@ -8,7 +8,7 @@ namespace Sawczyn.EFDesigner.EFModel.EditingOnly public partial class GeneratedTextTransformation { #region Template - // EFDesigner v3.0.3 + // EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner @@ -48,8 +48,8 @@ protected override List GatherModelAttributeSegments(ModelAttribute mode { string enumName = modelAttribute.InitialValue.Split('.').First(); string enumValue = modelAttribute.InitialValue.Split('.').Last(); - string enumFQN = modelAttribute.ModelClass.ModelRoot.Enums.FirstOrDefault(e => e.Name == enumName).FullName; - segments.Add($"HasDefaultValue({enumFQN}.{enumValue.Trim()})"); + string enumFQN = modelAttribute.ModelClass.ModelRoot.Enums.FirstOrDefault(e => e.Name == enumName)?.FullName ?? enumName; + segments.Add($"HasDefaultValue({enumFQN.Trim()}.{enumValue.Trim()})"); } else { diff --git a/src/DslPackage/TextTemplates/EditingOnly/EFCoreDesigner.cs b/src/DslPackage/TextTemplates/EditingOnly/EFCoreDesigner.cs index 2d8db31c0..b7781e41f 100644 --- a/src/DslPackage/TextTemplates/EditingOnly/EFCoreDesigner.cs +++ b/src/DslPackage/TextTemplates/EditingOnly/EFCoreDesigner.cs @@ -1,5 +1,5 @@ #region Template -// EFDesigner v3.0.3 +// EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/EditingOnly/EFCoreModelGenerator.cs b/src/DslPackage/TextTemplates/EditingOnly/EFCoreModelGenerator.cs index dc8745ea2..ab6ac87b5 100644 --- a/src/DslPackage/TextTemplates/EditingOnly/EFCoreModelGenerator.cs +++ b/src/DslPackage/TextTemplates/EditingOnly/EFCoreModelGenerator.cs @@ -11,7 +11,7 @@ namespace Sawczyn.EFDesigner.EFModel.EditingOnly public partial class GeneratedTextTransformation { #region Template - // EFDesigner v3.0.3 + // EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/EditingOnly/EFDesigner.cs b/src/DslPackage/TextTemplates/EditingOnly/EFDesigner.cs index df753d685..2c9c0338f 100644 --- a/src/DslPackage/TextTemplates/EditingOnly/EFDesigner.cs +++ b/src/DslPackage/TextTemplates/EditingOnly/EFDesigner.cs @@ -25,7 +25,7 @@ public void WriteLine(string textToAppend) { } #region Template - // EFDesigner v3.0.3 + // EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/EditingOnly/EFModelFileManager.cs b/src/DslPackage/TextTemplates/EditingOnly/EFModelFileManager.cs index bbdcaaa3d..0dcd15e87 100644 --- a/src/DslPackage/TextTemplates/EditingOnly/EFModelFileManager.cs +++ b/src/DslPackage/TextTemplates/EditingOnly/EFModelFileManager.cs @@ -16,7 +16,7 @@ public partial class GeneratedTextTransformation { #region Template - // EFDesigner v3.0.3 + // EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/EditingOnly/EFModelGenerator.cs b/src/DslPackage/TextTemplates/EditingOnly/EFModelGenerator.cs index e877c56c1..763c58c7c 100644 --- a/src/DslPackage/TextTemplates/EditingOnly/EFModelGenerator.cs +++ b/src/DslPackage/TextTemplates/EditingOnly/EFModelGenerator.cs @@ -12,7 +12,7 @@ namespace Sawczyn.EFDesigner.EFModel.EditingOnly public partial class GeneratedTextTransformation { #region Template - // EFDesigner v3.0.3 + // EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner @@ -419,6 +419,9 @@ protected List GetRequiredParameters(ModelClass modelClass, bool? haveDe ? x.InitialValue.Trim(quote[0]) : x.InitialValue); + if (x.FQPrimitiveType == "decimal") + value += "m"; + return $"{x.FQPrimitiveType} {x.Name.ToLower()} = {quote}{value}{quote}"; })); } @@ -689,9 +692,14 @@ protected void WriteConstructor(ModelClass modelClass) ? "'" : string.Empty; + string initialValue = modelAttribute.InitialValue; + + if (modelAttribute.Type == "decimal") + initialValue += "m"; + Output(quote.Length > 0 - ? $"this.{modelAttribute.Name} = {quote}{FullyQualified(modelAttribute.InitialValue.Trim(quote[0]))}{quote};" - : $"this.{modelAttribute.Name} = {quote}{FullyQualified(modelAttribute.InitialValue)}{quote};"); + ? $"this.{modelAttribute.Name} = {quote}{FullyQualified(initialValue.Trim(quote[0]))}{quote};" + : $"this.{modelAttribute.Name} = {quote}{FullyQualified(initialValue)}{quote};"); } // all required navigation properties that aren't a 1..1 relationship @@ -703,9 +711,12 @@ protected void WriteConstructor(ModelClass modelClass) string parameterName = requiredNavigationProperty.PropertyName.ToLower(); Output($"if ({parameterName} == null) throw new ArgumentNullException(nameof({parameterName}));"); - Output(requiredNavigationProperty.IsCollection - ? $"{requiredNavigationProperty.PropertyName}.Add({parameterName});" - : $"this.{requiredNavigationProperty.PropertyName} = {parameterName};"); + if (!requiredNavigationProperty.ConstructorParameterOnly) + { + Output(requiredNavigationProperty.IsCollection + ? $"{requiredNavigationProperty.PropertyName}.Add({parameterName});" + : $"this.{requiredNavigationProperty.PropertyName} = {parameterName};"); + } if (!string.IsNullOrEmpty(otherSide.PropertyName)) { @@ -770,11 +781,10 @@ protected void WriteConstructorComments(ModelClass modelClass) && x.SetterVisibility == SetterAccessModifier.Public)) Output($@"/// {string.Join(" ", GenerateCommentBody(requiredAttribute.Summary))}"); - // TODO: Add comment if available foreach (NavigationProperty requiredNavigationProperty in modelClass.AllRequiredNavigationProperties() .Where(np => np.AssociationObject.SourceMultiplicity != Sawczyn.EFDesigner.EFModel.Multiplicity.One || np.AssociationObject.TargetMultiplicity != Sawczyn.EFDesigner.EFModel.Multiplicity.One)) - Output($@"/// "); + Output($@"/// {string.Join(" ", GenerateCommentBody(requiredNavigationProperty.Summary))}"); } protected void WriteDbContextComments() @@ -809,10 +819,14 @@ protected void WriteDefaultConstructorBody(ModelClass modelClass) : modelAttribute.Type == "Char" ? "'" : string.Empty; + string initialValue = modelAttribute.InitialValue; + + if (modelAttribute.Type == "decimal") + initialValue += "m"; Output(quote.Length == 1 - ? $"{modelAttribute.Name} = {quote}{FullyQualified(modelAttribute.InitialValue.Trim(quote[0]))}{quote};" - : $"{modelAttribute.Name} = {quote}{FullyQualified(modelAttribute.InitialValue)}{quote};"); + ? $"{modelAttribute.Name} = {quote}{FullyQualified(initialValue.Trim(quote[0]))}{quote};" + : $"{modelAttribute.Name} = {quote}{FullyQualified(initialValue)}{quote};"); ++lineCount; } @@ -1094,7 +1108,12 @@ protected void WriteProperties(ModelClass modelClass) ? "'" : string.Empty; - segments.Add($"Default value = {quote}{FullyQualified(modelAttribute.InitialValue.Trim('"'))}{quote}"); + string initialValue = modelAttribute.InitialValue; + + if (modelAttribute.Type == "decimal") + initialValue += "m"; + + segments.Add($"Default value = {quote}{FullyQualified(initialValue.Trim('"'))}{quote}"); } string nullable = IsNullable(modelAttribute) diff --git a/src/DslPackage/TextTemplates/EditingOnly/MultipleOutputHelper.cs b/src/DslPackage/TextTemplates/EditingOnly/MultipleOutputHelper.cs index 6450af048..7f60cd76e 100644 --- a/src/DslPackage/TextTemplates/EditingOnly/MultipleOutputHelper.cs +++ b/src/DslPackage/TextTemplates/EditingOnly/MultipleOutputHelper.cs @@ -1,5 +1,5 @@ #region Template -// EFDesigner v3.0.3 +// EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/EditingOnly/VSIntegration.cs b/src/DslPackage/TextTemplates/EditingOnly/VSIntegration.cs index 09e28a052..f2939d39f 100644 --- a/src/DslPackage/TextTemplates/EditingOnly/VSIntegration.cs +++ b/src/DslPackage/TextTemplates/EditingOnly/VSIntegration.cs @@ -14,7 +14,7 @@ public partial class GeneratedTextTransformation { #region Template - // EFDesigner v3.0.3 + // EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/MultipleOutputHelper.ttinclude b/src/DslPackage/TextTemplates/MultipleOutputHelper.ttinclude index d1212998f..a1e1e070a 100644 --- a/src/DslPackage/TextTemplates/MultipleOutputHelper.ttinclude +++ b/src/DslPackage/TextTemplates/MultipleOutputHelper.ttinclude @@ -23,7 +23,7 @@ #><#@ import namespace="System.Data.Entity.Design.PluralizationServices" #><#@ import namespace="Microsoft.VisualStudio.TextTemplating" #><#+ -// EFDesigner v3.0.3 +// EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/TextTemplates/VSIntegration.ttinclude b/src/DslPackage/TextTemplates/VSIntegration.ttinclude index ea0cb9d1a..7af8e58b2 100644 --- a/src/DslPackage/TextTemplates/VSIntegration.ttinclude +++ b/src/DslPackage/TextTemplates/VSIntegration.ttinclude @@ -23,7 +23,7 @@ #><#@ import namespace="System.Data.Entity.Design.PluralizationServices" #><#@ import namespace="Microsoft.VisualStudio.TextTemplating" #><#+ - // EFDesigner v3.0.3 + // EFDesigner v3.0.4 // Copyright (c) 2017-2021 Michael Sawczyn // https://github.com/msawczyn/EFDesigner diff --git a/src/DslPackage/source.extension.vsixmanifest b/src/DslPackage/source.extension.vsixmanifest index f7b6dc034..766ae7177 100644 --- a/src/DslPackage/source.extension.vsixmanifest +++ b/src/DslPackage/source.extension.vsixmanifest @@ -1,7 +1,7 @@  - + Entity Framework Visual Editor Entity Framework visual editor for EF6, EFCore and beyond. Logo.ico diff --git a/src/Testing/EF6/EF6NetCore3/AllFeatureModel.cs b/src/Testing/EF6/EF6NetCore3/AllFeatureModel.cs index 6153a7d78..eed1f8ddf 100644 --- a/src/Testing/EF6/EF6NetCore3/AllFeatureModel.cs +++ b/src/Testing/EF6/EF6NetCore3/AllFeatureModel.cs @@ -1 +1,1778 @@  +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Data.Entity.Spatial; + +namespace Testing +{ + public partial class AllPropertyTypesRequired + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesRequired() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesRequired CreateAllPropertyTypesRequiredUnsafe() + { + return new AllPropertyTypesRequired(); + } + + /// + /// Public constructor with required data + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, TimeSpan timeattr, string stringattr) + { + this.BinaryAttr = binaryattr; + + this.BooleanAttr = booleanattr; + + this.ByteAttr = byteattr; + + this.DateTimeAttr = datetimeattr; + + this.DateTimeOffsetAttr = datetimeoffsetattr; + + this.DecimalAttr = decimalattr; + + this.DoubleAttr = doubleattr; + + this.GuidAttr = guidattr; + + this.Int16Attr = int16attr; + + this.Int32Attr = int32attr; + + this.Int64Attr = int64attr; + + this.SingleAttr = singleattr; + + this.TimeAttr = timeattr; + + if (string.IsNullOrEmpty(stringattr)) throw new ArgumentNullException(nameof(stringattr)); + this.StringAttr = stringattr; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static AllPropertyTypesRequired Create(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, TimeSpan timeattr, string stringattr) + { + return new AllPropertyTypesRequired(binaryattr, booleanattr, byteattr, datetimeattr, datetimeoffsetattr, decimalattr, doubleattr, guidattr, int16attr, int32attr, int64attr, singleattr, timeattr, stringattr); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + protected int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + /// + /// Required + /// + [Required] + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool oldValue, ref bool newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool result); + + /// + /// Required + /// + [Required] + public bool BooleanAttr + { + get + { + bool value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte oldValue, ref byte newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte result); + + /// + /// Required + /// + [Required] + public byte ByteAttr + { + get + { + byte value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime oldValue, ref DateTime newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime result); + + /// + /// Required + /// + [Required] + public DateTime DateTimeAttr + { + get + { + DateTime value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset oldValue, ref DateTimeOffset newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset result); + + /// + /// Required + /// + [Required] + public DateTimeOffset DateTimeOffsetAttr + { + get + { + DateTimeOffset value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal oldValue, ref decimal newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal result); + + /// + /// Required + /// + [Required] + public decimal DecimalAttr + { + get + { + decimal value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double oldValue, ref double newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double result); + + /// + /// Required + /// + [Required] + public double DoubleAttr + { + get + { + double value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid oldValue, ref Guid newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid result); + + /// + /// Required + /// + [Required] + public Guid GuidAttr + { + get + { + Guid value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short oldValue, ref short newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short result); + + /// + /// Required + /// + [Required] + public short Int16Attr + { + get + { + short value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int result); + + /// + /// Required + /// + [Required] + public int Int32Attr + { + get + { + int value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long oldValue, ref long newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long result); + + /// + /// Required + /// + [Required] + public long Int64Attr + { + get + { + long value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single oldValue, ref Single newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single result); + + /// + /// Required + /// + [Required] + public Single SingleAttr + { + get + { + Single value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan oldValue, ref TimeSpan newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan result); + + /// + /// Required + /// + [Required] + public TimeSpan TimeAttr + { + get + { + TimeSpan value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + /// + /// Required + /// + [Required] + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Data.Entity.Spatial; + +namespace Testing +{ + public partial class AllPropertyTypesOptional + { + partial void Init(); + + /// + /// Default constructor + /// + public AllPropertyTypesOptional() + { + Init(); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + protected int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool? _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool? oldValue, ref bool? newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool? result); + + public bool? BooleanAttr + { + get + { + bool? value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool? oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte? _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte? oldValue, ref byte? newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte? result); + + public byte? ByteAttr + { + get + { + byte? value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte? oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime? _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime? oldValue, ref DateTime? newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime? result); + + public DateTime? DateTimeAttr + { + get + { + DateTime? value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime? oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset? _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset? oldValue, ref DateTimeOffset? newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset? result); + + public DateTimeOffset? DateTimeOffsetAttr + { + get + { + DateTimeOffset? value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset? oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal? _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal? oldValue, ref decimal? newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal? result); + + public decimal? DecimalAttr + { + get + { + decimal? value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal? oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double? _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double? oldValue, ref double? newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double? result); + + public double? DoubleAttr + { + get + { + double? value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double? oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid? _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid? oldValue, ref Guid? newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid? result); + + public Guid? GuidAttr + { + get + { + Guid? value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid? oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short? _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short? oldValue, ref short? newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short? result); + + public short? Int16Attr + { + get + { + short? value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short? oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int? _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int? oldValue, ref int? newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int? result); + + public int? Int32Attr + { + get + { + int? value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int? oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long? _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long? oldValue, ref long? newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long? result); + + public long? Int64Attr + { + get + { + long? value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long? oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single? _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single? oldValue, ref Single? newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single? result); + + public Single? SingleAttr + { + get + { + Single? value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single? oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan? _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan? oldValue, ref TimeSpan? newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan? result); + + public TimeSpan? TimeAttr + { + get + { + TimeSpan? value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan? oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Data.Entity.Spatial; + +namespace Testing +{ + public partial class UParentRequired + { + partial void Init(); + + /// + /// Default constructor + /// + public UParentRequired() + { + UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Data.Entity.Spatial; + +namespace Testing +{ + /// + /// x + /// + [System.ComponentModel.Description("x")] + public partial class UParentOptional: global::Testing.HiddenEntity + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentOptional(): base() + { + PropertyInChild = "hello"; + UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentOptional CreateUParentOptionalUnsafe() + { + return new UParentOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentOptional(global::Testing.UChild uchildrequired) + { + this.PropertyInChild = "hello"; + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + this.UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentOptional Create(global::Testing.UChild uchildrequired) + { + return new UParentOptional(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for PropertyInChild + /// + protected string _propertyInChild; + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before setting. + /// + partial void SetPropertyInChild(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before returning. + /// + partial void GetPropertyInChild(ref string result); + + /// + /// Default value = "hello" + /// + public string PropertyInChild + { + get + { + string value = _propertyInChild; + GetPropertyInChild(ref value); + return (_propertyInChild = value); + } + set + { + string oldValue = _propertyInChild; + SetPropertyInChild(oldValue, ref value); + if (oldValue != value) + { + _propertyInChild = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + /// + /// x + /// + [Description("x")] + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + /// + /// h + /// + [Description("h")] + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Data.Entity.Spatial; + +namespace Testing +{ + public partial class UParentCollection + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentCollection() + { + UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentCollection CreateUParentCollectionUnsafe() + { + return new UParentCollection(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentCollection(global::Testing.UChild uchildrequired) + { + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + this.UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentCollection Create(global::Testing.UChild uchildrequired) + { + return new UParentCollection(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Data.Entity.Spatial; + +namespace Testing +{ + public partial class UChild + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UChild() + { + // NOTE: This class has one-to-one associations with UChild. + // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other. + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UChild CreateUChildUnsafe() + { + return new UChild(); + } + + /// + /// Public constructor with required data + /// diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Context/AllFeatureModel.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Context/AllFeatureModel.generated.cs index 97aea8b4c..562986eac 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Context/AllFeatureModel.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Context/AllFeatureModel.generated.cs @@ -197,7 +197,7 @@ protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelB modelBuilder.Entity().ToTable("Masters").HasKey(t => t.Id); modelBuilder.Entity().Property(t => t.Id).IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); - modelBuilder.Entity().HasMany(x => x.Children).WithRequired().Map(x => x.MapKey("Master_Children_Id")); + modelBuilder.Entity().HasMany(x => x.Children).WithRequired().Map(x => x.MapKey("MasterChildrenId")); modelBuilder.Entity().ToTable("ParserTests").HasKey(t => t.Id); modelBuilder.Entity().Property(t => t.Id).IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.None); @@ -220,13 +220,13 @@ protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelB modelBuilder.Entity(); modelBuilder.Entity().HasOptional(x => x.UChildOptional).WithOptionalDependent(); - modelBuilder.Entity().HasMany(x => x.UChildCollection).WithOptional().Map(x => x.MapKey("UParentOptional_UChildCollection_Id")); + modelBuilder.Entity().HasMany(x => x.UChildCollection).WithOptional().Map(x => x.MapKey("UParentOptionalUChildCollectionId")); modelBuilder.Entity().HasRequired(x => x.UChildRequired).WithOptional(); modelBuilder.Entity().ToTable("UParentRequireds").HasKey(t => t.Id); modelBuilder.Entity().Property(t => t.Id).IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); modelBuilder.Entity().HasRequired(x => x.UChildRequired).WithRequiredDependent(); - modelBuilder.Entity().HasMany(x => x.UChildCollection).WithRequired().Map(x => x.MapKey("UParentRequired_UChildCollection_Id")); + modelBuilder.Entity().HasMany(x => x.UChildCollection).WithRequired().Map(x => x.MapKey("UParentRequiredUChildCollectionId")); modelBuilder.Entity().HasOptional(x => x.UChildOptional).WithRequired().WillCascadeOnDelete(true); OnModelCreatedImpl(modelBuilder); diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/AbstractBaseClass.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/AbstractBaseClass.generated.cs index 3353e2694..f4e0834fa 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/AbstractBaseClass.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/AbstractBaseClass.generated.cs @@ -40,7 +40,6 @@ protected AbstractBaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/AllPropertyTypesOptional.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/AllPropertyTypesOptional.generated.cs index 842f5c5e4..3d575882d 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/AllPropertyTypesOptional.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/AllPropertyTypesOptional.generated.cs @@ -61,7 +61,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/AllPropertyTypesRequired.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/AllPropertyTypesRequired.generated.cs index 71b7fc2dd..03e7799ea 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/AllPropertyTypesRequired.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/AllPropertyTypesRequired.generated.cs @@ -87,7 +87,6 @@ public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteat if (string.IsNullOrEmpty(stringattr)) throw new ArgumentNullException(nameof(stringattr)); this.StringAttr = stringattr; - Init(); } @@ -143,7 +142,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/BChild.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/BChild.generated.cs index 7bacb8ea7..f9adfdf0f 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/BChild.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/BChild.generated.cs @@ -61,14 +61,15 @@ public BChild(global::Testing.BParentRequired bparentrequired, global::Testing.B if (bparentrequired == null) throw new ArgumentNullException(nameof(bparentrequired)); this.BParentRequired = bparentrequired; + bparentrequired.BChildOptional = this; if (bparentrequired_2 == null) throw new ArgumentNullException(nameof(bparentrequired_2)); this.BParentRequired_2 = bparentrequired_2; + bparentrequired_2.BChildCollection.Add(this); this.BParentCollection = new System.Collections.ObjectModel.ObservableCollection(); this.BParentCollection_1 = new System.Collections.ObjectModel.ObservableCollection(); this.BParentCollection_2 = new System.Collections.ObjectModel.ObservableCollection(); - Init(); } @@ -112,7 +113,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/BParentCollection.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/BParentCollection.generated.cs index 0e6e96396..0e2e2fd96 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/BParentCollection.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/BParentCollection.generated.cs @@ -50,9 +50,9 @@ public BParentCollection(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; + bchildrequired.BParentCollection.Add(this); this.BChildCollection = new System.Collections.ObjectModel.ObservableCollection(); - Init(); } @@ -95,7 +95,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -110,8 +110,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -136,7 +147,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get @@ -149,8 +164,19 @@ private set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/BParentOptional.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/BParentOptional.generated.cs index 806647949..98c7a0d86 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/BParentOptional.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/BParentOptional.generated.cs @@ -50,9 +50,9 @@ public BParentOptional(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; + bchildrequired.BParentOptional = this; this.BChildCollection = new System.Collections.ObjectModel.ObservableCollection(); - Init(); } @@ -95,7 +95,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -110,8 +110,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -136,7 +147,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get @@ -149,8 +164,19 @@ private set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/BParentRequired.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/BParentRequired.generated.cs index 12f9a0c02..82d865e46 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/BParentRequired.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/BParentRequired.generated.cs @@ -64,7 +64,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -79,8 +79,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional @@ -102,8 +113,19 @@ protected set } } + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -128,7 +150,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/BaseClass.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/BaseClass.generated.cs index d5d203554..4bc2c5c1c 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/BaseClass.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/BaseClass.generated.cs @@ -48,7 +48,6 @@ public BaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/BaseClassWithRequiredProperties.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/BaseClassWithRequiredProperties.generated.cs index ede9bbf22..1c3e5878d 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/BaseClassWithRequiredProperties.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/BaseClassWithRequiredProperties.generated.cs @@ -48,7 +48,6 @@ public BaseClassWithRequiredProperties(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } @@ -91,7 +90,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/Child.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/Child.generated.cs index 24c750b01..1895dd5c2 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/Child.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/Child.generated.cs @@ -51,12 +51,12 @@ public Child(global::Testing.Child parent, global::Testing.Master _master0) { if (parent == null) throw new ArgumentNullException(nameof(parent)); this.Parent = parent; + parent.Children.Add(this); if (_master0 == null) throw new ArgumentNullException(nameof(_master0)); _master0.Children.Add(this); this.Children = new System.Collections.ObjectModel.ObservableCollection(); - Init(); } @@ -100,7 +100,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -115,7 +115,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/ConcreteDerivedClass.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/ConcreteDerivedClass.generated.cs index d8e84122f..addea6f3b 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/ConcreteDerivedClass.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/ConcreteDerivedClass.generated.cs @@ -48,7 +48,6 @@ public ConcreteDerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs index e69317163..cccbada76 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs @@ -52,7 +52,6 @@ public ConcreteDerivedClassWithRequiredProperties(string property1, string prope if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/DerivedClass.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/DerivedClass.generated.cs index 26776231a..ab2b80bb1 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/DerivedClass.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/DerivedClass.generated.cs @@ -48,7 +48,6 @@ public DerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/HiddenEntity.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/HiddenEntity.generated.cs index 0568e94fe..cde47273c 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/HiddenEntity.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/HiddenEntity.generated.cs @@ -61,7 +61,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/Master.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/Master.generated.cs index 2ae49defd..cb4445aee 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/Master.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/Master.generated.cs @@ -63,7 +63,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -78,7 +78,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/ParserTest.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/ParserTest.generated.cs index 9538d5ba2..533ca94c7 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/ParserTest.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/ParserTest.generated.cs @@ -47,7 +47,6 @@ public ParserTest(long foo) { this.foo = foo; - Init(); } @@ -90,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/RenamedColumn.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/RenamedColumn.generated.cs index d39ea6ec6..cbda1dac1 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/RenamedColumn.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/RenamedColumn.generated.cs @@ -61,7 +61,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/SpatialProperties.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/SpatialProperties.generated.cs index 8923c5cbf..ed58c8353 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/SpatialProperties.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/SpatialProperties.generated.cs @@ -104,7 +104,6 @@ public SpatialProperties(DbGeography attrgeography, DbGeography attrgeographycol if (attrgeometrypoint == null) throw new ArgumentNullException(nameof(attrgeometrypoint)); this.AttrGeometryPoint = attrgeometrypoint; - Init(); } @@ -161,7 +160,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/UChild.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/UChild.generated.cs index a98e0cce7..96dfabc60 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/UChild.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/UChild.generated.cs @@ -58,7 +58,6 @@ public UChild(global::Testing.UParentRequired _uparentrequired1, global::Testing if (_uparentrequired2 == null) throw new ArgumentNullException(nameof(_uparentrequired2)); _uparentrequired2.UChildOptional = this; - Init(); } @@ -102,7 +101,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/UParentCollection.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/UParentCollection.generated.cs index 57e7d17e8..e1d459a94 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/UParentCollection.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/UParentCollection.generated.cs @@ -52,7 +52,6 @@ public UParentCollection(global::Testing.UChild uchildrequired) this.UChildRequired = uchildrequired; this.UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); - Init(); } @@ -95,7 +94,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -110,8 +109,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -136,7 +146,11 @@ protected set } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -149,8 +163,19 @@ private set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/UParentOptional.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/UParentOptional.generated.cs index cdc50803b..9132853fb 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/UParentOptional.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/UParentOptional.generated.cs @@ -22,7 +22,8 @@ namespace Testing /// /// x /// - public partial class UParentOptional: global::Testing.HiddenEntity, INotifyPropertyChanged + [System.ComponentModel.Description("x")] + public partial class UParentOptional: global::Testing.HiddenEntity { partial void Init(); @@ -57,7 +58,6 @@ public UParentOptional(global::Testing.UChild uchildrequired) this.UChildRequired = uchildrequired; this.UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); - Init(); } @@ -113,13 +113,25 @@ public string PropertyInChild * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); /// /// x /// + [Description("x")] public virtual global::Testing.UChild UChildOptional { get @@ -139,10 +151,15 @@ public string PropertyInChild } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + /// /// h /// + [Description("h")] public virtual ICollection UChildCollection { get @@ -155,8 +172,19 @@ private set } } + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -181,13 +209,6 @@ private set } } - public virtual event PropertyChangedEventHandler PropertyChanged; - - protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } - } } diff --git a/src/Testing/EF6/EF6NetCore3/Generated/Entities/UParentRequired.generated.cs b/src/Testing/EF6/EF6NetCore3/Generated/Entities/UParentRequired.generated.cs index 304681e19..49aace31d 100644 --- a/src/Testing/EF6/EF6NetCore3/Generated/Entities/UParentRequired.generated.cs +++ b/src/Testing/EF6/EF6NetCore3/Generated/Entities/UParentRequired.generated.cs @@ -64,7 +64,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -79,8 +79,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -105,7 +116,11 @@ protected set } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -118,8 +133,19 @@ private set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EF6/EF6NetFramework/AllFeatureModel.cs b/src/Testing/EF6/EF6NetFramework/AllFeatureModel.cs index 6153a7d78..0182e3190 100644 --- a/src/Testing/EF6/EF6NetFramework/AllFeatureModel.cs +++ b/src/Testing/EF6/EF6NetFramework/AllFeatureModel.cs @@ -1 +1,1784 @@  +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +// Produced by Entity Framework Visual Editor v3.0.4.5 +// Source: https://github.com/msawczyn/EFDesigner +// Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner +// Documentation: https://msawczyn.github.io/EFDesigner/ +// License (MIT): https://github.com/msawczyn/EFDesigner/blob/master/LICENSE +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Data.Entity.Spatial; + +namespace Testing +{ + public partial class AllPropertyTypesRequired + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesRequired() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesRequired CreateAllPropertyTypesRequiredUnsafe() + { + return new AllPropertyTypesRequired(); + } + + /// + /// Public constructor with required data + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, TimeSpan timeattr, string stringattr) + { + this.BinaryAttr = binaryattr; + + this.BooleanAttr = booleanattr; + + this.ByteAttr = byteattr; + + this.DateTimeAttr = datetimeattr; + + this.DateTimeOffsetAttr = datetimeoffsetattr; + + this.DecimalAttr = decimalattr; + + this.DoubleAttr = doubleattr; + + this.GuidAttr = guidattr; + + this.Int16Attr = int16attr; + + this.Int32Attr = int32attr; + + this.Int64Attr = int64attr; + + this.SingleAttr = singleattr; + + this.TimeAttr = timeattr; + + if (string.IsNullOrEmpty(stringattr)) throw new ArgumentNullException(nameof(stringattr)); + this.StringAttr = stringattr; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static AllPropertyTypesRequired Create(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, TimeSpan timeattr, string stringattr) + { + return new AllPropertyTypesRequired(binaryattr, booleanattr, byteattr, datetimeattr, datetimeoffsetattr, decimalattr, doubleattr, guidattr, int16attr, int32attr, int64attr, singleattr, timeattr, stringattr); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + protected int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + /// + /// Required + /// + [Required] + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool oldValue, ref bool newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool result); + + /// + /// Required + /// + [Required] + public bool BooleanAttr + { + get + { + bool value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte oldValue, ref byte newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte result); + + /// + /// Required + /// + [Required] + public byte ByteAttr + { + get + { + byte value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime oldValue, ref DateTime newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime result); + + /// + /// Required + /// + [Required] + public DateTime DateTimeAttr + { + get + { + DateTime value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset oldValue, ref DateTimeOffset newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset result); + + /// + /// Required + /// + [Required] + public DateTimeOffset DateTimeOffsetAttr + { + get + { + DateTimeOffset value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal oldValue, ref decimal newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal result); + + /// + /// Required + /// + [Required] + public decimal DecimalAttr + { + get + { + decimal value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double oldValue, ref double newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double result); + + /// + /// Required + /// + [Required] + public double DoubleAttr + { + get + { + double value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid oldValue, ref Guid newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid result); + + /// + /// Required + /// + [Required] + public Guid GuidAttr + { + get + { + Guid value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short oldValue, ref short newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short result); + + /// + /// Required + /// + [Required] + public short Int16Attr + { + get + { + short value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int result); + + /// + /// Required + /// + [Required] + public int Int32Attr + { + get + { + int value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long oldValue, ref long newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long result); + + /// + /// Required + /// + [Required] + public long Int64Attr + { + get + { + long value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single oldValue, ref Single newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single result); + + /// + /// Required + /// + [Required] + public Single SingleAttr + { + get + { + Single value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan oldValue, ref TimeSpan newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan result); + + /// + /// Required + /// + [Required] + public TimeSpan TimeAttr + { + get + { + TimeSpan value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + /// + /// Required + /// + [Required] + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Data.Entity.Spatial; + +namespace Testing +{ + public partial class AllPropertyTypesOptional + { + partial void Init(); + + /// + /// Default constructor + /// + public AllPropertyTypesOptional() + { + Init(); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + protected int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool? _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool? oldValue, ref bool? newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool? result); + + public bool? BooleanAttr + { + get + { + bool? value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool? oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte? _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte? oldValue, ref byte? newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte? result); + + public byte? ByteAttr + { + get + { + byte? value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte? oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime? _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime? oldValue, ref DateTime? newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime? result); + + public DateTime? DateTimeAttr + { + get + { + DateTime? value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime? oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset? _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset? oldValue, ref DateTimeOffset? newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset? result); + + public DateTimeOffset? DateTimeOffsetAttr + { + get + { + DateTimeOffset? value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset? oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal? _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal? oldValue, ref decimal? newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal? result); + + public decimal? DecimalAttr + { + get + { + decimal? value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal? oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double? _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double? oldValue, ref double? newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double? result); + + public double? DoubleAttr + { + get + { + double? value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double? oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid? _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid? oldValue, ref Guid? newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid? result); + + public Guid? GuidAttr + { + get + { + Guid? value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid? oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short? _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short? oldValue, ref short? newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short? result); + + public short? Int16Attr + { + get + { + short? value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short? oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int? _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int? oldValue, ref int? newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int? result); + + public int? Int32Attr + { + get + { + int? value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int? oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long? _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long? oldValue, ref long? newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long? result); + + public long? Int64Attr + { + get + { + long? value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long? oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single? _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single? oldValue, ref Single? newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single? result); + + public Single? SingleAttr + { + get + { + Single? value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single? oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan? _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan? oldValue, ref TimeSpan? newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan? result); + + public TimeSpan? TimeAttr + { + get + { + TimeSpan? value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan? oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Data.Entity.Spatial; + +namespace Testing +{ + public partial class UParentRequired + { + partial void Init(); + + /// + /// Default constructor + /// + public UParentRequired() + { + UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Data.Entity.Spatial; + +namespace Testing +{ + /// + /// x + /// + [System.ComponentModel.Description("x")] + public partial class UParentOptional: global::Testing.HiddenEntity + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentOptional(): base() + { + PropertyInChild = "hello"; + UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentOptional CreateUParentOptionalUnsafe() + { + return new UParentOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentOptional(global::Testing.UChild uchildrequired) + { + this.PropertyInChild = "hello"; + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + this.UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentOptional Create(global::Testing.UChild uchildrequired) + { + return new UParentOptional(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for PropertyInChild + /// + protected string _propertyInChild; + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before setting. + /// + partial void SetPropertyInChild(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before returning. + /// + partial void GetPropertyInChild(ref string result); + + /// + /// Default value = "hello" + /// + public string PropertyInChild + { + get + { + string value = _propertyInChild; + GetPropertyInChild(ref value); + return (_propertyInChild = value); + } + set + { + string oldValue = _propertyInChild; + SetPropertyInChild(oldValue, ref value); + if (oldValue != value) + { + _propertyInChild = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + /// + /// x + /// + [Description("x")] + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + /// + /// h + /// + [Description("h")] + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Data.Entity.Spatial; + +namespace Testing +{ + public partial class UParentCollection + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentCollection() + { + UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentCollection CreateUParentCollectionUnsafe() + { + return new UParentCollection(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentCollection(global::Testing.UChild uchildrequired) + { + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + this.UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentCollection Create(global::Testing.UChild uchildrequired) + { + return new UParentCollection(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Data.Entity.Spatial; + +namespace Testing +{ + public partial class UChild + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UChild() + { + // NOTE: This class has one-to-one associations with UChild. + // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other. + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UChild CreateUChildUnsafe() + { + return new UChild(); + } + + /// + /// Public constructor with required data + /// diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Context/AllFeatureModel.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Context/AllFeatureModel.generated.cs index 171076421..1a581f49a 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Context/AllFeatureModel.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Context/AllFeatureModel.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -138,7 +138,7 @@ protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelB modelBuilder.HasDefaultSchema("dbo"); - modelBuilder.Entity().ToTable("AbstractBaseClasses").HasKey(t => t.Id); + modelBuilder.Entity().ToTable("AbstractBaseClasses"); modelBuilder.Entity().ToTable("AllPropertyTypesOptionals").HasKey(t => t.Id); modelBuilder.Entity().Property(t => t.Id).IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.None); @@ -160,7 +160,7 @@ protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelB modelBuilder.Entity().Property(t => t.TimeAttr).IsRequired(); modelBuilder.Entity().Property(t => t.StringAttr).IsRequired(); - modelBuilder.Entity().ToTable("BaseClasses").HasKey(t => t.Id); + modelBuilder.Entity().ToTable("BaseClasses"); modelBuilder.Entity().ToTable("BaseClassWithRequiredProperties").HasKey(t => t.Id); modelBuilder.Entity().Property(t => t.Id).IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); @@ -191,12 +191,12 @@ protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelB modelBuilder.Entity().Property(t => t.Id).IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); modelBuilder.Entity().HasRequired(x => x.Parent).WithMany(x => x.Children).Map(x => x.MapKey("ParentId")); - modelBuilder.Entity().ToTable("ConcreteDerivedClasses").HasKey(t => t.Id); + modelBuilder.Entity().ToTable("ConcreteDerivedClasses"); - modelBuilder.Entity().ToTable("ConcreteDerivedClassWithRequiredProperties").HasKey(t => t.Id); + modelBuilder.Entity().ToTable("ConcreteDerivedClassWithRequiredProperties"); modelBuilder.Entity().Property(t => t.Property1).IsRequired(); - modelBuilder.Entity().ToTable("DerivedClasses").HasKey(t => new { t.Id1, t.Id }); + modelBuilder.Entity().ToTable("DerivedClasses").HasKey(t => t.Id1); modelBuilder.Entity().Property(t => t.Id1).IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); modelBuilder.Entity().ToTable("HiddenEntities").HasKey(t => t.Id); @@ -204,7 +204,7 @@ protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelB modelBuilder.Entity().ToTable("Masters").HasKey(t => t.Id); modelBuilder.Entity().Property(t => t.Id).IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); - modelBuilder.Entity().HasMany(x => x.Children).WithRequired().Map(x => x.MapKey("Master_Children_Id")); + modelBuilder.Entity().HasMany(x => x.Children).WithRequired().Map(x => x.MapKey("MasterChildrenId")); modelBuilder.Entity().ToTable("ParserTests").HasKey(t => t.Id); modelBuilder.Entity().Property(t => t.Id).IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.None); @@ -225,15 +225,15 @@ protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelB modelBuilder.Entity().HasMany(x => x.UChildCollection).WithMany().Map(x => { x.ToTable("UParentCollection_x_UChildCollection"); x.MapLeftKey("UParentCollection_Id"); x.MapRightKey("UChild_Id"); }); modelBuilder.Entity().HasOptional(x => x.UChildOptional).WithMany().Map(x => x.MapKey("UChildOptionalId")); - modelBuilder.Entity().ToTable("UParentOptionals").HasKey(t => t.Id); + modelBuilder.Entity().ToTable("UParentOptionals"); modelBuilder.Entity().HasOptional(x => x.UChildOptional).WithOptionalDependent(); - modelBuilder.Entity().HasMany(x => x.UChildCollection).WithOptional().Map(x => x.MapKey("UParentOptional_UChildCollection_Id")); + modelBuilder.Entity().HasMany(x => x.UChildCollection).WithOptional().Map(x => x.MapKey("UParentOptionalUChildCollectionId")); modelBuilder.Entity().HasRequired(x => x.UChildRequired).WithOptional(); modelBuilder.Entity().ToTable("UParentRequireds").HasKey(t => t.Id); modelBuilder.Entity().Property(t => t.Id).IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); modelBuilder.Entity().HasRequired(x => x.UChildRequired).WithRequiredDependent(); - modelBuilder.Entity().HasMany(x => x.UChildCollection).WithRequired().Map(x => x.MapKey("UParentRequired_UChildCollection_Id")); + modelBuilder.Entity().HasMany(x => x.UChildCollection).WithRequired().Map(x => x.MapKey("UParentRequiredUChildCollectionId")); modelBuilder.Entity().HasOptional(x => x.UChildOptional).WithRequired().WillCascadeOnDelete(true); OnModelCreatedImpl(modelBuilder); diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Context/AllFeatureModelDbMigrationConfiguration.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Context/AllFeatureModelDbMigrationConfiguration.generated.cs index a798fd2b4..30077c571 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Context/AllFeatureModelDbMigrationConfiguration.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Context/AllFeatureModelDbMigrationConfiguration.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/AbstractBaseClass.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/AbstractBaseClass.generated.cs index 7633ded61..5690939f7 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/AbstractBaseClass.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/AbstractBaseClass.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -46,7 +46,6 @@ protected AbstractBaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/AllPropertyTypesOptional.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/AllPropertyTypesOptional.generated.cs index 71ac437a6..d9cf76d80 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/AllPropertyTypesOptional.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/AllPropertyTypesOptional.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -67,7 +67,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/AllPropertyTypesRequired.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/AllPropertyTypesRequired.generated.cs index 721c9ca6b..94fc6ccb7 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/AllPropertyTypesRequired.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/AllPropertyTypesRequired.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -93,7 +93,6 @@ public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteat if (string.IsNullOrEmpty(stringattr)) throw new ArgumentNullException(nameof(stringattr)); this.StringAttr = stringattr; - Init(); } @@ -149,7 +148,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/BChild.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/BChild.generated.cs index 0cecaa8dd..ece0e0875 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/BChild.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/BChild.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -67,14 +67,15 @@ public BChild(global::Testing.BParentRequired bparentrequired, global::Testing.B if (bparentrequired == null) throw new ArgumentNullException(nameof(bparentrequired)); this.BParentRequired = bparentrequired; + bparentrequired.BChildOptional = this; if (bparentrequired_2 == null) throw new ArgumentNullException(nameof(bparentrequired_2)); this.BParentRequired_2 = bparentrequired_2; + bparentrequired_2.BChildCollection.Add(this); this.BParentCollection = new System.Collections.ObjectModel.ObservableCollection(); this.BParentCollection_1 = new System.Collections.ObjectModel.ObservableCollection(); this.BParentCollection_2 = new System.Collections.ObjectModel.ObservableCollection(); - Init(); } @@ -118,7 +119,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/BParentCollection.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/BParentCollection.generated.cs index 1de06fddd..895a7b8d4 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/BParentCollection.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/BParentCollection.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -56,9 +56,9 @@ public BParentCollection(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; + bchildrequired.BParentCollection.Add(this); this.BChildCollection = new System.Collections.ObjectModel.ObservableCollection(); - Init(); } @@ -101,7 +101,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -116,8 +116,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -142,7 +153,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get @@ -155,8 +170,19 @@ private set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/BParentOptional.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/BParentOptional.generated.cs index e10337eb5..fefc0a9e6 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/BParentOptional.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/BParentOptional.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -56,9 +56,9 @@ public BParentOptional(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; + bchildrequired.BParentOptional = this; this.BChildCollection = new System.Collections.ObjectModel.ObservableCollection(); - Init(); } @@ -101,7 +101,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -116,8 +116,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -142,7 +153,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get @@ -155,8 +170,19 @@ private set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/BParentRequired.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/BParentRequired.generated.cs index 9b31c394b..5739ceec7 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/BParentRequired.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/BParentRequired.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -70,7 +70,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -85,8 +85,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional @@ -108,8 +119,19 @@ protected set } } + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -134,7 +156,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/BaseClass.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/BaseClass.generated.cs index 341059bc0..9cef744e9 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/BaseClass.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/BaseClass.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -54,7 +54,6 @@ public BaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/BaseClassWithRequiredProperties.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/BaseClassWithRequiredProperties.generated.cs index bb11478e3..3dc0f8810 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/BaseClassWithRequiredProperties.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/BaseClassWithRequiredProperties.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -54,7 +54,6 @@ public BaseClassWithRequiredProperties(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } @@ -97,7 +96,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/Child.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/Child.generated.cs index 0f86b4e5d..c08c5be2f 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/Child.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/Child.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -57,12 +57,12 @@ public Child(global::Testing.Child parent, global::Testing.Master _master0) { if (parent == null) throw new ArgumentNullException(nameof(parent)); this.Parent = parent; + parent.Children.Add(this); if (_master0 == null) throw new ArgumentNullException(nameof(_master0)); _master0.Children.Add(this); this.Children = new System.Collections.ObjectModel.ObservableCollection(); - Init(); } @@ -106,7 +106,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -121,7 +121,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/ConcreteDerivedClass.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/ConcreteDerivedClass.generated.cs index 698faec50..2bf056a64 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/ConcreteDerivedClass.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/ConcreteDerivedClass.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -54,7 +54,6 @@ public ConcreteDerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs index f135d60dc..cd0cd503e 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -58,7 +58,6 @@ public ConcreteDerivedClassWithRequiredProperties(string property1, string prope if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/DerivedClass.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/DerivedClass.generated.cs index b77f70ab0..9ebb7ce28 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/DerivedClass.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/DerivedClass.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -54,7 +54,6 @@ public DerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } @@ -161,7 +160,7 @@ public int Id1 GetId1(ref value); return (_id1 = value); } - protected set + set { int oldValue = _id1; SetId1(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/HiddenEntity.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/HiddenEntity.generated.cs index 02237acc7..14cc1b719 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/HiddenEntity.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/HiddenEntity.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -67,7 +67,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/Master.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/Master.generated.cs index 7a4844675..65a007086 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/Master.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/Master.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -69,7 +69,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -84,7 +84,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/ParserTest.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/ParserTest.generated.cs index 9ba108783..3edb53287 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/ParserTest.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/ParserTest.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -53,7 +53,6 @@ public ParserTest(long foo) { this.foo = foo; - Init(); } @@ -96,7 +95,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/RenamedColumn.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/RenamedColumn.generated.cs index 628e23785..4e4c15000 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/RenamedColumn.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/RenamedColumn.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -67,7 +67,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/SpatialProperties.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/SpatialProperties.generated.cs index 51320c292..7f3d8bc60 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/SpatialProperties.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/SpatialProperties.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -110,7 +110,6 @@ public SpatialProperties(DbGeography attrgeography, DbGeography attrgeographycol if (attrgeometrypoint == null) throw new ArgumentNullException(nameof(attrgeometrypoint)); this.AttrGeometryPoint = attrgeometrypoint; - Init(); } @@ -167,7 +166,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/UChild.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/UChild.generated.cs index 10d2cd53a..c262f07a5 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/UChild.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/UChild.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -64,7 +64,6 @@ public UChild(global::Testing.UParentRequired _uparentrequired1, global::Testing if (_uparentrequired2 == null) throw new ArgumentNullException(nameof(_uparentrequired2)); _uparentrequired2.UChildOptional = this; - Init(); } @@ -108,7 +107,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/UParentCollection.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/UParentCollection.generated.cs index df552f352..4bc82ce35 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/UParentCollection.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/UParentCollection.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -58,7 +58,6 @@ public UParentCollection(global::Testing.UChild uchildrequired) this.UChildRequired = uchildrequired; this.UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); - Init(); } @@ -101,7 +100,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -116,8 +115,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -142,7 +152,11 @@ protected set } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -155,8 +169,19 @@ private set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/UParentOptional.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/UParentOptional.generated.cs index 33147e3be..5a41cd8f3 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/UParentOptional.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/UParentOptional.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -28,7 +28,8 @@ namespace Testing /// /// x /// - public partial class UParentOptional: global::Testing.HiddenEntity, INotifyPropertyChanged + [System.ComponentModel.Description("x")] + public partial class UParentOptional: global::Testing.HiddenEntity { partial void Init(); @@ -63,7 +64,6 @@ public UParentOptional(global::Testing.UChild uchildrequired) this.UChildRequired = uchildrequired; this.UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); - Init(); } @@ -119,13 +119,25 @@ public string PropertyInChild * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); /// /// x /// + [Description("x")] public virtual global::Testing.UChild UChildOptional { get @@ -145,10 +157,15 @@ public string PropertyInChild } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + /// /// h /// + [Description("h")] public virtual ICollection UChildCollection { get @@ -161,8 +178,19 @@ private set } } + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -187,13 +215,6 @@ private set } } - public virtual event PropertyChangedEventHandler PropertyChanged; - - protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } - } } diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Entities/UParentRequired.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Entities/UParentRequired.generated.cs index 28e95fbff..169f1ca09 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Entities/UParentRequired.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Entities/UParentRequired.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -70,7 +70,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -85,8 +85,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -111,7 +122,11 @@ protected set } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -124,8 +139,19 @@ private set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Enums/Enum1.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Enums/Enum1.generated.cs index dfa839238..7709980bd 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Enums/Enum1.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Enums/Enum1.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ diff --git a/src/Testing/EF6/EF6NetFramework/Generated/Enums/FlagEnum.generated.cs b/src/Testing/EF6/EF6NetFramework/Generated/Enums/FlagEnum.generated.cs index 0ff250599..8066cf714 100644 --- a/src/Testing/EF6/EF6NetFramework/Generated/Enums/FlagEnum.generated.cs +++ b/src/Testing/EF6/EF6NetFramework/Generated/Enums/FlagEnum.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ diff --git a/src/Testing/EF6/EF6NetStandard/AllFeatureModel.cs b/src/Testing/EF6/EF6NetStandard/AllFeatureModel.cs index 6153a7d78..df68f9dc0 100644 --- a/src/Testing/EF6/EF6NetStandard/AllFeatureModel.cs +++ b/src/Testing/EF6/EF6NetStandard/AllFeatureModel.cs @@ -1 +1,551 @@  +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Data.Entity.Spatial; + +namespace Testing +{ + public partial class AllPropertyTypesRequired + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesRequired() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesRequired CreateAllPropertyTypesRequiredUnsafe() + { + return new AllPropertyTypesRequired(); + } + + /// + /// Public constructor with required data + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, TimeSpan timeattr, string stringattr) + { + this.BinaryAttr = binaryattr; + + this.BooleanAttr = booleanattr; + + this.ByteAttr = byteattr; + + this.DateTimeAttr = datetimeattr; + + this.DateTimeOffsetAttr = datetimeoffsetattr; + + this.DecimalAttr = decimalattr; + + this.DoubleAttr = doubleattr; + + this.GuidAttr = guidattr; + + this.Int16Attr = int16attr; + + this.Int32Attr = int32attr; + + this.Int64Attr = int64attr; + + this.SingleAttr = singleattr; + + this.TimeAttr = timeattr; + + if (string.IsNullOrEmpty(stringattr)) throw new ArgumentNullException(nameof(stringattr)); + this.StringAttr = stringattr; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static AllPropertyTypesRequired Create(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, TimeSpan timeattr, string stringattr) + { + return new AllPropertyTypesRequired(binaryattr, booleanattr, byteattr, datetimeattr, datetimeoffsetattr, decimalattr, doubleattr, guidattr, int16attr, int32attr, int64attr, singleattr, timeattr, stringattr); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Identity, Required + /// + [Key] + [Required] + public int Id { get; set; } + + /// + /// Required + /// + [Required] + public byte[] BinaryAttr { get; set; } + + /// + /// Required + /// + [Required] + public bool BooleanAttr { get; set; } + + /// + /// Required + /// + [Required] + public byte ByteAttr { get; set; } + + /// + /// Required + /// + [Required] + public DateTime DateTimeAttr { get; set; } + + /// + /// Required + /// + [Required] + public DateTimeOffset DateTimeOffsetAttr { get; set; } + + /// + /// Required + /// + [Required] + public decimal DecimalAttr { get; set; } + + /// + /// Required + /// + [Required] + public double DoubleAttr { get; set; } + + /// + /// Required + /// + [Required] + public Guid GuidAttr { get; set; } + + /// + /// Required + /// + [Required] + public short Int16Attr { get; set; } + + /// + /// Required + /// + [Required] + public int Int32Attr { get; set; } + + /// + /// Required + /// + [Required] + public long Int64Attr { get; set; } + + /// + /// Required + /// + [Required] + public Single SingleAttr { get; set; } + + /// + /// Required + /// + [Required] + public TimeSpan TimeAttr { get; set; } + + /// + /// Required + /// + [Required] + public string StringAttr { get; set; } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Data.Entity.Spatial; + +namespace Testing +{ + public partial class AllPropertyTypesOptional + { + partial void Init(); + + /// + /// Default constructor + /// + public AllPropertyTypesOptional() + { + Init(); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Identity, Required + /// + [Key] + [Required] + public int Id { get; set; } + + public byte[] BinaryAttr { get; set; } + + public bool? BooleanAttr { get; set; } + + public byte? ByteAttr { get; set; } + + public DateTime? DateTimeAttr { get; set; } + + public DateTimeOffset? DateTimeOffsetAttr { get; set; } + + public decimal? DecimalAttr { get; set; } + + public double? DoubleAttr { get; set; } + + public Guid? GuidAttr { get; set; } + + public short? Int16Attr { get; set; } + + public int? Int32Attr { get; set; } + + public long? Int64Attr { get; set; } + + public Single? SingleAttr { get; set; } + + public TimeSpan? TimeAttr { get; set; } + + public string StringAttr { get; set; } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Data.Entity.Spatial; + +namespace Testing +{ + public partial class UParentRequired + { + partial void Init(); + + /// + /// Default constructor + /// + public UParentRequired() + { + UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id { get; set; } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired { get; set; } + + public virtual ICollection UChildCollection { get; private set; } + + public virtual global::Testing.UChild UChildOptional { get; set; } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Data.Entity.Spatial; + +namespace Testing +{ + /// + /// x + /// + [System.ComponentModel.Description("x")] + public partial class UParentOptional: global::Testing.HiddenEntity + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentOptional(): base() + { + PropertyInChild = "hello"; + UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentOptional CreateUParentOptionalUnsafe() + { + return new UParentOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentOptional(global::Testing.UChild uchildrequired) + { + this.PropertyInChild = "hello"; + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + this.UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentOptional Create(global::Testing.UChild uchildrequired) + { + return new UParentOptional(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Default value = "hello" + /// + public string PropertyInChild { get; set; } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// x + /// + [Description("x")] + public virtual global::Testing.UChild UChildOptional { get; set; } + + /// + /// h + /// + [Description("h")] + public virtual ICollection UChildCollection { get; private set; } + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired { get; set; } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Data.Entity.Spatial; + +namespace Testing +{ + public partial class UParentCollection + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentCollection() + { + UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentCollection CreateUParentCollectionUnsafe() + { + return new UParentCollection(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentCollection(global::Testing.UChild uchildrequired) + { + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + this.UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentCollection Create(global::Testing.UChild uchildrequired) + { + return new UParentCollection(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id { get; set; } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired { get; set; } + + public virtual ICollection UChildCollection { get; private set; } + + public virtual global::Testing.UChild UChildOptional { get; set; } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Data.Entity.Spatial; + +namespace Testing +{ + public partial class UChild + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UChild() + { + // NOTE: This class has one-to-one associations with UChild. + // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other. + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UChild CreateUChildUnsafe() + { + return new UChild(); + } + + /// + /// Public constructor with required data + /// diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Context/AllFeatureModel.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Context/AllFeatureModel.generated.cs index c03b8e8de..63b8cbd8a 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Context/AllFeatureModel.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Context/AllFeatureModel.generated.cs @@ -197,7 +197,7 @@ protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelB modelBuilder.Entity().ToTable("Masters").HasKey(t => t.Id); modelBuilder.Entity().Property(t => t.Id).IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); - modelBuilder.Entity().HasMany(x => x.Children).WithRequired().Map(x => x.MapKey("Master_Children_Id")); + modelBuilder.Entity().HasMany(x => x.Children).WithRequired().Map(x => x.MapKey("MasterChildrenId")); modelBuilder.Entity().ToTable("ParserTests").HasKey(t => t.Id); modelBuilder.Entity().Property(t => t.Id).IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.None); @@ -220,13 +220,13 @@ protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelB modelBuilder.Entity(); modelBuilder.Entity().HasOptional(x => x.UChildOptional).WithOptionalDependent(); - modelBuilder.Entity().HasMany(x => x.UChildCollection).WithOptional().Map(x => x.MapKey("UParentOptional_UChildCollection_Id")); + modelBuilder.Entity().HasMany(x => x.UChildCollection).WithOptional().Map(x => x.MapKey("UParentOptionalUChildCollectionId")); modelBuilder.Entity().HasRequired(x => x.UChildRequired).WithOptional(); modelBuilder.Entity().ToTable("UParentRequireds").HasKey(t => t.Id); modelBuilder.Entity().Property(t => t.Id).IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); modelBuilder.Entity().HasRequired(x => x.UChildRequired).WithRequiredDependent(); - modelBuilder.Entity().HasMany(x => x.UChildCollection).WithRequired().Map(x => x.MapKey("UParentRequired_UChildCollection_Id")); + modelBuilder.Entity().HasMany(x => x.UChildCollection).WithRequired().Map(x => x.MapKey("UParentRequiredUChildCollectionId")); modelBuilder.Entity().HasOptional(x => x.UChildOptional).WithRequired().WillCascadeOnDelete(true); OnModelCreatedImpl(modelBuilder); diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/AbstractBaseClass.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/AbstractBaseClass.generated.cs index 3353e2694..f4e0834fa 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/AbstractBaseClass.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/AbstractBaseClass.generated.cs @@ -40,7 +40,6 @@ protected AbstractBaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/AllPropertyTypesOptional.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/AllPropertyTypesOptional.generated.cs index 842f5c5e4..50048a83f 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/AllPropertyTypesOptional.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/AllPropertyTypesOptional.generated.cs @@ -35,490 +35,40 @@ public AllPropertyTypesOptional() * Properties *************************************************************************/ - /// - /// Backing field for Id - /// - protected int _id; - /// - /// When provided in a partial class, allows value of Id to be changed before setting. - /// - partial void SetId(int oldValue, ref int newValue); - /// - /// When provided in a partial class, allows value of Id to be changed before returning. - /// - partial void GetId(ref int result); - /// /// Identity, Required /// [Key] [Required] - public int Id - { - get - { - int value = _id; - GetId(ref value); - return (_id = value); - } - protected set - { - int oldValue = _id; - SetId(oldValue, ref value); - if (oldValue != value) - { - _id = value; - } - } - } + public int Id { get; set; } - /// - /// Backing field for BinaryAttr - /// - protected byte[] _binaryAttr; - /// - /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. - /// - partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); - /// - /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. - /// - partial void GetBinaryAttr(ref byte[] result); - - public byte[] BinaryAttr - { - get - { - byte[] value = _binaryAttr; - GetBinaryAttr(ref value); - return (_binaryAttr = value); - } - set - { - byte[] oldValue = _binaryAttr; - SetBinaryAttr(oldValue, ref value); - if (oldValue != value) - { - _binaryAttr = value; - } - } - } + public byte[] BinaryAttr { get; set; } - /// - /// Backing field for BooleanAttr - /// - protected bool? _booleanAttr; - /// - /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. - /// - partial void SetBooleanAttr(bool? oldValue, ref bool? newValue); - /// - /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. - /// - partial void GetBooleanAttr(ref bool? result); + public bool? BooleanAttr { get; set; } - public bool? BooleanAttr - { - get - { - bool? value = _booleanAttr; - GetBooleanAttr(ref value); - return (_booleanAttr = value); - } - set - { - bool? oldValue = _booleanAttr; - SetBooleanAttr(oldValue, ref value); - if (oldValue != value) - { - _booleanAttr = value; - } - } - } + public byte? ByteAttr { get; set; } - /// - /// Backing field for ByteAttr - /// - protected byte? _byteAttr; - /// - /// When provided in a partial class, allows value of ByteAttr to be changed before setting. - /// - partial void SetByteAttr(byte? oldValue, ref byte? newValue); - /// - /// When provided in a partial class, allows value of ByteAttr to be changed before returning. - /// - partial void GetByteAttr(ref byte? result); + public DateTime? DateTimeAttr { get; set; } - public byte? ByteAttr - { - get - { - byte? value = _byteAttr; - GetByteAttr(ref value); - return (_byteAttr = value); - } - set - { - byte? oldValue = _byteAttr; - SetByteAttr(oldValue, ref value); - if (oldValue != value) - { - _byteAttr = value; - } - } - } + public DateTimeOffset? DateTimeOffsetAttr { get; set; } - /// - /// Backing field for DateTimeAttr - /// - protected DateTime? _dateTimeAttr; - /// - /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. - /// - partial void SetDateTimeAttr(DateTime? oldValue, ref DateTime? newValue); - /// - /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. - /// - partial void GetDateTimeAttr(ref DateTime? result); + public decimal? DecimalAttr { get; set; } - public DateTime? DateTimeAttr - { - get - { - DateTime? value = _dateTimeAttr; - GetDateTimeAttr(ref value); - return (_dateTimeAttr = value); - } - set - { - DateTime? oldValue = _dateTimeAttr; - SetDateTimeAttr(oldValue, ref value); - if (oldValue != value) - { - _dateTimeAttr = value; - } - } - } + public double? DoubleAttr { get; set; } - /// - /// Backing field for DateTimeOffsetAttr - /// - protected DateTimeOffset? _dateTimeOffsetAttr; - /// - /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. - /// - partial void SetDateTimeOffsetAttr(DateTimeOffset? oldValue, ref DateTimeOffset? newValue); - /// - /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. - /// - partial void GetDateTimeOffsetAttr(ref DateTimeOffset? result); + public Guid? GuidAttr { get; set; } - public DateTimeOffset? DateTimeOffsetAttr - { - get - { - DateTimeOffset? value = _dateTimeOffsetAttr; - GetDateTimeOffsetAttr(ref value); - return (_dateTimeOffsetAttr = value); - } - set - { - DateTimeOffset? oldValue = _dateTimeOffsetAttr; - SetDateTimeOffsetAttr(oldValue, ref value); - if (oldValue != value) - { - _dateTimeOffsetAttr = value; - } - } - } + public short? Int16Attr { get; set; } - /// - /// Backing field for DecimalAttr - /// - protected decimal? _decimalAttr; - /// - /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. - /// - partial void SetDecimalAttr(decimal? oldValue, ref decimal? newValue); - /// - /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. - /// - partial void GetDecimalAttr(ref decimal? result); + public int? Int32Attr { get; set; } - public decimal? DecimalAttr - { - get - { - decimal? value = _decimalAttr; - GetDecimalAttr(ref value); - return (_decimalAttr = value); - } - set - { - decimal? oldValue = _decimalAttr; - SetDecimalAttr(oldValue, ref value); - if (oldValue != value) - { - _decimalAttr = value; - } - } - } + public long? Int64Attr { get; set; } - /// - /// Backing field for DoubleAttr - /// - protected double? _doubleAttr; - /// - /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. - /// - partial void SetDoubleAttr(double? oldValue, ref double? newValue); - /// - /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. - /// - partial void GetDoubleAttr(ref double? result); + public Single? SingleAttr { get; set; } - public double? DoubleAttr - { - get - { - double? value = _doubleAttr; - GetDoubleAttr(ref value); - return (_doubleAttr = value); - } - set - { - double? oldValue = _doubleAttr; - SetDoubleAttr(oldValue, ref value); - if (oldValue != value) - { - _doubleAttr = value; - } - } - } + public TimeSpan? TimeAttr { get; set; } - /// - /// Backing field for GuidAttr - /// - protected Guid? _guidAttr; - /// - /// When provided in a partial class, allows value of GuidAttr to be changed before setting. - /// - partial void SetGuidAttr(Guid? oldValue, ref Guid? newValue); - /// - /// When provided in a partial class, allows value of GuidAttr to be changed before returning. - /// - partial void GetGuidAttr(ref Guid? result); - - public Guid? GuidAttr - { - get - { - Guid? value = _guidAttr; - GetGuidAttr(ref value); - return (_guidAttr = value); - } - set - { - Guid? oldValue = _guidAttr; - SetGuidAttr(oldValue, ref value); - if (oldValue != value) - { - _guidAttr = value; - } - } - } - - /// - /// Backing field for Int16Attr - /// - protected short? _int16Attr; - /// - /// When provided in a partial class, allows value of Int16Attr to be changed before setting. - /// - partial void SetInt16Attr(short? oldValue, ref short? newValue); - /// - /// When provided in a partial class, allows value of Int16Attr to be changed before returning. - /// - partial void GetInt16Attr(ref short? result); - - public short? Int16Attr - { - get - { - short? value = _int16Attr; - GetInt16Attr(ref value); - return (_int16Attr = value); - } - set - { - short? oldValue = _int16Attr; - SetInt16Attr(oldValue, ref value); - if (oldValue != value) - { - _int16Attr = value; - } - } - } - - /// - /// Backing field for Int32Attr - /// - protected int? _int32Attr; - /// - /// When provided in a partial class, allows value of Int32Attr to be changed before setting. - /// - partial void SetInt32Attr(int? oldValue, ref int? newValue); - /// - /// When provided in a partial class, allows value of Int32Attr to be changed before returning. - /// - partial void GetInt32Attr(ref int? result); - - public int? Int32Attr - { - get - { - int? value = _int32Attr; - GetInt32Attr(ref value); - return (_int32Attr = value); - } - set - { - int? oldValue = _int32Attr; - SetInt32Attr(oldValue, ref value); - if (oldValue != value) - { - _int32Attr = value; - } - } - } - - /// - /// Backing field for Int64Attr - /// - protected long? _int64Attr; - /// - /// When provided in a partial class, allows value of Int64Attr to be changed before setting. - /// - partial void SetInt64Attr(long? oldValue, ref long? newValue); - /// - /// When provided in a partial class, allows value of Int64Attr to be changed before returning. - /// - partial void GetInt64Attr(ref long? result); - - public long? Int64Attr - { - get - { - long? value = _int64Attr; - GetInt64Attr(ref value); - return (_int64Attr = value); - } - set - { - long? oldValue = _int64Attr; - SetInt64Attr(oldValue, ref value); - if (oldValue != value) - { - _int64Attr = value; - } - } - } - - /// - /// Backing field for SingleAttr - /// - protected Single? _singleAttr; - /// - /// When provided in a partial class, allows value of SingleAttr to be changed before setting. - /// - partial void SetSingleAttr(Single? oldValue, ref Single? newValue); - /// - /// When provided in a partial class, allows value of SingleAttr to be changed before returning. - /// - partial void GetSingleAttr(ref Single? result); - - public Single? SingleAttr - { - get - { - Single? value = _singleAttr; - GetSingleAttr(ref value); - return (_singleAttr = value); - } - set - { - Single? oldValue = _singleAttr; - SetSingleAttr(oldValue, ref value); - if (oldValue != value) - { - _singleAttr = value; - } - } - } - - /// - /// Backing field for TimeAttr - /// - protected TimeSpan? _timeAttr; - /// - /// When provided in a partial class, allows value of TimeAttr to be changed before setting. - /// - partial void SetTimeAttr(TimeSpan? oldValue, ref TimeSpan? newValue); - /// - /// When provided in a partial class, allows value of TimeAttr to be changed before returning. - /// - partial void GetTimeAttr(ref TimeSpan? result); - - public TimeSpan? TimeAttr - { - get - { - TimeSpan? value = _timeAttr; - GetTimeAttr(ref value); - return (_timeAttr = value); - } - set - { - TimeSpan? oldValue = _timeAttr; - SetTimeAttr(oldValue, ref value); - if (oldValue != value) - { - _timeAttr = value; - } - } - } - - /// - /// Backing field for StringAttr - /// - protected string _stringAttr; - /// - /// When provided in a partial class, allows value of StringAttr to be changed before setting. - /// - partial void SetStringAttr(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of StringAttr to be changed before returning. - /// - partial void GetStringAttr(ref string result); - - public string StringAttr - { - get - { - string value = _stringAttr; - GetStringAttr(ref value); - return (_stringAttr = value); - } - set - { - string oldValue = _stringAttr; - SetStringAttr(oldValue, ref value); - if (oldValue != value) - { - _stringAttr = value; - } - } - } + public string StringAttr { get; set; } } } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/AllPropertyTypesRequired.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/AllPropertyTypesRequired.generated.cs index 71b7fc2dd..a6757d223 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/AllPropertyTypesRequired.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/AllPropertyTypesRequired.generated.cs @@ -87,7 +87,6 @@ public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteat if (string.IsNullOrEmpty(stringattr)) throw new ArgumentNullException(nameof(stringattr)); this.StringAttr = stringattr; - Init(); } @@ -117,546 +116,96 @@ public static AllPropertyTypesRequired Create(byte[] binaryattr, bool booleanatt * Properties *************************************************************************/ - /// - /// Backing field for Id - /// - protected int _id; - /// - /// When provided in a partial class, allows value of Id to be changed before setting. - /// - partial void SetId(int oldValue, ref int newValue); - /// - /// When provided in a partial class, allows value of Id to be changed before returning. - /// - partial void GetId(ref int result); - /// /// Identity, Required /// [Key] [Required] - public int Id - { - get - { - int value = _id; - GetId(ref value); - return (_id = value); - } - protected set - { - int oldValue = _id; - SetId(oldValue, ref value); - if (oldValue != value) - { - _id = value; - } - } - } - - /// - /// Backing field for BinaryAttr - /// - protected byte[] _binaryAttr; - /// - /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. - /// - partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); - /// - /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. - /// - partial void GetBinaryAttr(ref byte[] result); + public int Id { get; set; } /// /// Required /// [Required] - public byte[] BinaryAttr - { - get - { - byte[] value = _binaryAttr; - GetBinaryAttr(ref value); - return (_binaryAttr = value); - } - set - { - byte[] oldValue = _binaryAttr; - SetBinaryAttr(oldValue, ref value); - if (oldValue != value) - { - _binaryAttr = value; - } - } - } - - /// - /// Backing field for BooleanAttr - /// - protected bool _booleanAttr; - /// - /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. - /// - partial void SetBooleanAttr(bool oldValue, ref bool newValue); - /// - /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. - /// - partial void GetBooleanAttr(ref bool result); + public byte[] BinaryAttr { get; set; } /// /// Required /// [Required] - public bool BooleanAttr - { - get - { - bool value = _booleanAttr; - GetBooleanAttr(ref value); - return (_booleanAttr = value); - } - set - { - bool oldValue = _booleanAttr; - SetBooleanAttr(oldValue, ref value); - if (oldValue != value) - { - _booleanAttr = value; - } - } - } - - /// - /// Backing field for ByteAttr - /// - protected byte _byteAttr; - /// - /// When provided in a partial class, allows value of ByteAttr to be changed before setting. - /// - partial void SetByteAttr(byte oldValue, ref byte newValue); - /// - /// When provided in a partial class, allows value of ByteAttr to be changed before returning. - /// - partial void GetByteAttr(ref byte result); + public bool BooleanAttr { get; set; } /// /// Required /// [Required] - public byte ByteAttr - { - get - { - byte value = _byteAttr; - GetByteAttr(ref value); - return (_byteAttr = value); - } - set - { - byte oldValue = _byteAttr; - SetByteAttr(oldValue, ref value); - if (oldValue != value) - { - _byteAttr = value; - } - } - } - - /// - /// Backing field for DateTimeAttr - /// - protected DateTime _dateTimeAttr; - /// - /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. - /// - partial void SetDateTimeAttr(DateTime oldValue, ref DateTime newValue); - /// - /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. - /// - partial void GetDateTimeAttr(ref DateTime result); + public byte ByteAttr { get; set; } /// /// Required /// [Required] - public DateTime DateTimeAttr - { - get - { - DateTime value = _dateTimeAttr; - GetDateTimeAttr(ref value); - return (_dateTimeAttr = value); - } - set - { - DateTime oldValue = _dateTimeAttr; - SetDateTimeAttr(oldValue, ref value); - if (oldValue != value) - { - _dateTimeAttr = value; - } - } - } - - /// - /// Backing field for DateTimeOffsetAttr - /// - protected DateTimeOffset _dateTimeOffsetAttr; - /// - /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. - /// - partial void SetDateTimeOffsetAttr(DateTimeOffset oldValue, ref DateTimeOffset newValue); - /// - /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. - /// - partial void GetDateTimeOffsetAttr(ref DateTimeOffset result); + public DateTime DateTimeAttr { get; set; } /// /// Required /// [Required] - public DateTimeOffset DateTimeOffsetAttr - { - get - { - DateTimeOffset value = _dateTimeOffsetAttr; - GetDateTimeOffsetAttr(ref value); - return (_dateTimeOffsetAttr = value); - } - set - { - DateTimeOffset oldValue = _dateTimeOffsetAttr; - SetDateTimeOffsetAttr(oldValue, ref value); - if (oldValue != value) - { - _dateTimeOffsetAttr = value; - } - } - } - - /// - /// Backing field for DecimalAttr - /// - protected decimal _decimalAttr; - /// - /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. - /// - partial void SetDecimalAttr(decimal oldValue, ref decimal newValue); - /// - /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. - /// - partial void GetDecimalAttr(ref decimal result); + public DateTimeOffset DateTimeOffsetAttr { get; set; } /// /// Required /// [Required] - public decimal DecimalAttr - { - get - { - decimal value = _decimalAttr; - GetDecimalAttr(ref value); - return (_decimalAttr = value); - } - set - { - decimal oldValue = _decimalAttr; - SetDecimalAttr(oldValue, ref value); - if (oldValue != value) - { - _decimalAttr = value; - } - } - } - - /// - /// Backing field for DoubleAttr - /// - protected double _doubleAttr; - /// - /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. - /// - partial void SetDoubleAttr(double oldValue, ref double newValue); - /// - /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. - /// - partial void GetDoubleAttr(ref double result); + public decimal DecimalAttr { get; set; } /// /// Required /// [Required] - public double DoubleAttr - { - get - { - double value = _doubleAttr; - GetDoubleAttr(ref value); - return (_doubleAttr = value); - } - set - { - double oldValue = _doubleAttr; - SetDoubleAttr(oldValue, ref value); - if (oldValue != value) - { - _doubleAttr = value; - } - } - } - - /// - /// Backing field for GuidAttr - /// - protected Guid _guidAttr; - /// - /// When provided in a partial class, allows value of GuidAttr to be changed before setting. - /// - partial void SetGuidAttr(Guid oldValue, ref Guid newValue); - /// - /// When provided in a partial class, allows value of GuidAttr to be changed before returning. - /// - partial void GetGuidAttr(ref Guid result); + public double DoubleAttr { get; set; } /// /// Required /// [Required] - public Guid GuidAttr - { - get - { - Guid value = _guidAttr; - GetGuidAttr(ref value); - return (_guidAttr = value); - } - set - { - Guid oldValue = _guidAttr; - SetGuidAttr(oldValue, ref value); - if (oldValue != value) - { - _guidAttr = value; - } - } - } - - /// - /// Backing field for Int16Attr - /// - protected short _int16Attr; - /// - /// When provided in a partial class, allows value of Int16Attr to be changed before setting. - /// - partial void SetInt16Attr(short oldValue, ref short newValue); - /// - /// When provided in a partial class, allows value of Int16Attr to be changed before returning. - /// - partial void GetInt16Attr(ref short result); + public Guid GuidAttr { get; set; } /// /// Required /// [Required] - public short Int16Attr - { - get - { - short value = _int16Attr; - GetInt16Attr(ref value); - return (_int16Attr = value); - } - set - { - short oldValue = _int16Attr; - SetInt16Attr(oldValue, ref value); - if (oldValue != value) - { - _int16Attr = value; - } - } - } - - /// - /// Backing field for Int32Attr - /// - protected int _int32Attr; - /// - /// When provided in a partial class, allows value of Int32Attr to be changed before setting. - /// - partial void SetInt32Attr(int oldValue, ref int newValue); - /// - /// When provided in a partial class, allows value of Int32Attr to be changed before returning. - /// - partial void GetInt32Attr(ref int result); + public short Int16Attr { get; set; } /// /// Required /// [Required] - public int Int32Attr - { - get - { - int value = _int32Attr; - GetInt32Attr(ref value); - return (_int32Attr = value); - } - set - { - int oldValue = _int32Attr; - SetInt32Attr(oldValue, ref value); - if (oldValue != value) - { - _int32Attr = value; - } - } - } - - /// - /// Backing field for Int64Attr - /// - protected long _int64Attr; - /// - /// When provided in a partial class, allows value of Int64Attr to be changed before setting. - /// - partial void SetInt64Attr(long oldValue, ref long newValue); - /// - /// When provided in a partial class, allows value of Int64Attr to be changed before returning. - /// - partial void GetInt64Attr(ref long result); + public int Int32Attr { get; set; } /// /// Required /// [Required] - public long Int64Attr - { - get - { - long value = _int64Attr; - GetInt64Attr(ref value); - return (_int64Attr = value); - } - set - { - long oldValue = _int64Attr; - SetInt64Attr(oldValue, ref value); - if (oldValue != value) - { - _int64Attr = value; - } - } - } - - /// - /// Backing field for SingleAttr - /// - protected Single _singleAttr; - /// - /// When provided in a partial class, allows value of SingleAttr to be changed before setting. - /// - partial void SetSingleAttr(Single oldValue, ref Single newValue); - /// - /// When provided in a partial class, allows value of SingleAttr to be changed before returning. - /// - partial void GetSingleAttr(ref Single result); + public long Int64Attr { get; set; } /// /// Required /// [Required] - public Single SingleAttr - { - get - { - Single value = _singleAttr; - GetSingleAttr(ref value); - return (_singleAttr = value); - } - set - { - Single oldValue = _singleAttr; - SetSingleAttr(oldValue, ref value); - if (oldValue != value) - { - _singleAttr = value; - } - } - } - - /// - /// Backing field for TimeAttr - /// - protected TimeSpan _timeAttr; - /// - /// When provided in a partial class, allows value of TimeAttr to be changed before setting. - /// - partial void SetTimeAttr(TimeSpan oldValue, ref TimeSpan newValue); - /// - /// When provided in a partial class, allows value of TimeAttr to be changed before returning. - /// - partial void GetTimeAttr(ref TimeSpan result); + public Single SingleAttr { get; set; } /// /// Required /// [Required] - public TimeSpan TimeAttr - { - get - { - TimeSpan value = _timeAttr; - GetTimeAttr(ref value); - return (_timeAttr = value); - } - set - { - TimeSpan oldValue = _timeAttr; - SetTimeAttr(oldValue, ref value); - if (oldValue != value) - { - _timeAttr = value; - } - } - } - - /// - /// Backing field for StringAttr - /// - protected string _stringAttr; - /// - /// When provided in a partial class, allows value of StringAttr to be changed before setting. - /// - partial void SetStringAttr(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of StringAttr to be changed before returning. - /// - partial void GetStringAttr(ref string result); + public TimeSpan TimeAttr { get; set; } /// /// Required /// [Required] - public string StringAttr - { - get - { - string value = _stringAttr; - GetStringAttr(ref value); - return (_stringAttr = value); - } - set - { - string oldValue = _stringAttr; - SetStringAttr(oldValue, ref value); - if (oldValue != value) - { - _stringAttr = value; - } - } - } + public string StringAttr { get; set; } } } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/BChild.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/BChild.generated.cs index 0dbd921ef..7e03c9331 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/BChild.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/BChild.generated.cs @@ -61,14 +61,15 @@ public BChild(global::Testing.BParentRequired bparentrequired, global::Testing.B if (bparentrequired == null) throw new ArgumentNullException(nameof(bparentrequired)); this.BParentRequired = bparentrequired; + bparentrequired.BChildOptional = this; if (bparentrequired_2 == null) throw new ArgumentNullException(nameof(bparentrequired_2)); this.BParentRequired_2 = bparentrequired_2; + bparentrequired_2.BChildCollection.Add(this); this.BParentCollection = new System.Collections.ObjectModel.ObservableCollection(); this.BParentCollection_1 = new System.Collections.ObjectModel.ObservableCollection(); this.BParentCollection_2 = new System.Collections.ObjectModel.ObservableCollection(); - Init(); } @@ -86,232 +87,43 @@ public static BChild Create(global::Testing.BParentRequired bparentrequired, glo * Properties *************************************************************************/ - /// - /// Backing field for Id - /// - internal int _id; - /// - /// When provided in a partial class, allows value of Id to be changed before setting. - /// - partial void SetId(int oldValue, ref int newValue); - /// - /// When provided in a partial class, allows value of Id to be changed before returning. - /// - partial void GetId(ref int result); - /// /// Identity, Indexed, Required /// [Key] [Required] - public int Id - { - get - { - int value = _id; - GetId(ref value); - return (_id = value); - } - protected set - { - int oldValue = _id; - SetId(oldValue, ref value); - if (oldValue != value) - { - _id = value; - } - } - } + public int Id { get; set; } /************************************************************************* * Navigation properties *************************************************************************/ - protected global::Testing.BParentRequired _bParentRequired; - partial void SetBParentRequired(global::Testing.BParentRequired oldValue, ref global::Testing.BParentRequired newValue); - partial void GetBParentRequired(ref global::Testing.BParentRequired result); - /// /// Required /// - public virtual global::Testing.BParentRequired BParentRequired - { - get - { - global::Testing.BParentRequired value = _bParentRequired; - GetBParentRequired(ref value); - return (_bParentRequired = value); - } - set - { - global::Testing.BParentRequired oldValue = _bParentRequired; - SetBParentRequired(oldValue, ref value); - if (oldValue != value) - { - _bParentRequired = value; - } - } - } - - protected global::Testing.BParentRequired _bParentRequired_1; - partial void SetBParentRequired_1(global::Testing.BParentRequired oldValue, ref global::Testing.BParentRequired newValue); - partial void GetBParentRequired_1(ref global::Testing.BParentRequired result); + public virtual global::Testing.BParentRequired BParentRequired { get; set; } /// /// Required /// - public virtual global::Testing.BParentRequired BParentRequired_1 - { - get - { - global::Testing.BParentRequired value = _bParentRequired_1; - GetBParentRequired_1(ref value); - return (_bParentRequired_1 = value); - } - set - { - global::Testing.BParentRequired oldValue = _bParentRequired_1; - SetBParentRequired_1(oldValue, ref value); - if (oldValue != value) - { - _bParentRequired_1 = value; - } - } - } - - protected global::Testing.BParentRequired _bParentRequired_2; - partial void SetBParentRequired_2(global::Testing.BParentRequired oldValue, ref global::Testing.BParentRequired newValue); - partial void GetBParentRequired_2(ref global::Testing.BParentRequired result); + public virtual global::Testing.BParentRequired BParentRequired_1 { get; set; } /// /// Required /// - public virtual global::Testing.BParentRequired BParentRequired_2 - { - get - { - global::Testing.BParentRequired value = _bParentRequired_2; - GetBParentRequired_2(ref value); - return (_bParentRequired_2 = value); - } - set - { - global::Testing.BParentRequired oldValue = _bParentRequired_2; - SetBParentRequired_2(oldValue, ref value); - if (oldValue != value) - { - _bParentRequired_2 = value; - } - } - } + public virtual global::Testing.BParentRequired BParentRequired_2 { get; set; } - protected ICollection _bParentCollection; - public virtual ICollection BParentCollection - { - get - { - return _bParentCollection; - } - private set - { - _bParentCollection = value; - } - } + public virtual ICollection BParentCollection { get; private set; } - protected ICollection _bParentCollection_1; - public virtual ICollection BParentCollection_1 - { - get - { - return _bParentCollection_1; - } - private set - { - _bParentCollection_1 = value; - } - } + public virtual ICollection BParentCollection_1 { get; private set; } - protected ICollection _bParentCollection_2; - public virtual ICollection BParentCollection_2 - { - get - { - return _bParentCollection_2; - } - private set - { - _bParentCollection_2 = value; - } - } + public virtual ICollection BParentCollection_2 { get; private set; } - protected global::Testing.BParentOptional _bParentOptional; - partial void SetBParentOptional(global::Testing.BParentOptional oldValue, ref global::Testing.BParentOptional newValue); - partial void GetBParentOptional(ref global::Testing.BParentOptional result); + public virtual global::Testing.BParentOptional BParentOptional { get; set; } - public virtual global::Testing.BParentOptional BParentOptional - { - get - { - global::Testing.BParentOptional value = _bParentOptional; - GetBParentOptional(ref value); - return (_bParentOptional = value); - } - set - { - global::Testing.BParentOptional oldValue = _bParentOptional; - SetBParentOptional(oldValue, ref value); - if (oldValue != value) - { - _bParentOptional = value; - } - } - } - - protected global::Testing.BParentOptional _bParentOptional_1; - partial void SetBParentOptional_1(global::Testing.BParentOptional oldValue, ref global::Testing.BParentOptional newValue); - partial void GetBParentOptional_1(ref global::Testing.BParentOptional result); - - public virtual global::Testing.BParentOptional BParentOptional_1 - { - get - { - global::Testing.BParentOptional value = _bParentOptional_1; - GetBParentOptional_1(ref value); - return (_bParentOptional_1 = value); - } - set - { - global::Testing.BParentOptional oldValue = _bParentOptional_1; - SetBParentOptional_1(oldValue, ref value); - if (oldValue != value) - { - _bParentOptional_1 = value; - } - } - } - - protected global::Testing.BParentOptional _bParentOptional_2; - partial void SetBParentOptional_2(global::Testing.BParentOptional oldValue, ref global::Testing.BParentOptional newValue); - partial void GetBParentOptional_2(ref global::Testing.BParentOptional result); + public virtual global::Testing.BParentOptional BParentOptional_1 { get; set; } - public virtual global::Testing.BParentOptional BParentOptional_2 - { - get - { - global::Testing.BParentOptional value = _bParentOptional_2; - GetBParentOptional_2(ref value); - return (_bParentOptional_2 = value); - } - set - { - global::Testing.BParentOptional oldValue = _bParentOptional_2; - SetBParentOptional_2(oldValue, ref value); - if (oldValue != value) - { - _bParentOptional_2 = value; - } - } - } + public virtual global::Testing.BParentOptional BParentOptional_2 { get; set; } } } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/BParentCollection.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/BParentCollection.generated.cs index 0e6e96396..049ae3d0e 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/BParentCollection.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/BParentCollection.generated.cs @@ -50,9 +50,9 @@ public BParentCollection(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; + bchildrequired.BParentCollection.Add(this); this.BChildCollection = new System.Collections.ObjectModel.ObservableCollection(); - Init(); } @@ -69,108 +69,25 @@ public static BParentCollection Create(global::Testing.BChild bchildrequired) * Properties *************************************************************************/ - /// - /// Backing field for Id - /// - internal int _id; - /// - /// When provided in a partial class, allows value of Id to be changed before setting. - /// - partial void SetId(int oldValue, ref int newValue); - /// - /// When provided in a partial class, allows value of Id to be changed before returning. - /// - partial void GetId(ref int result); - /// /// Identity, Indexed, Required /// [Key] [Required] - public int Id - { - get - { - int value = _id; - GetId(ref value); - return (_id = value); - } - protected set - { - int oldValue = _id; - SetId(oldValue, ref value); - if (oldValue != value) - { - _id = value; - } - } - } + public int Id { get; set; } /************************************************************************* * Navigation properties *************************************************************************/ - protected global::Testing.BChild _bChildRequired; - partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); - partial void GetBChildRequired(ref global::Testing.BChild result); - /// /// Required /// - public virtual global::Testing.BChild BChildRequired - { - get - { - global::Testing.BChild value = _bChildRequired; - GetBChildRequired(ref value); - return (_bChildRequired = value); - } - set - { - global::Testing.BChild oldValue = _bChildRequired; - SetBChildRequired(oldValue, ref value); - if (oldValue != value) - { - _bChildRequired = value; - } - } - } + public virtual global::Testing.BChild BChildRequired { get; set; } - protected ICollection _bChildCollection; - public virtual ICollection BChildCollection - { - get - { - return _bChildCollection; - } - private set - { - _bChildCollection = value; - } - } - - protected global::Testing.BChild _bChildOptional; - partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); - partial void GetBChildOptional(ref global::Testing.BChild result); + public virtual ICollection BChildCollection { get; private set; } - public virtual global::Testing.BChild BChildOptional - { - get - { - global::Testing.BChild value = _bChildOptional; - GetBChildOptional(ref value); - return (_bChildOptional = value); - } - set - { - global::Testing.BChild oldValue = _bChildOptional; - SetBChildOptional(oldValue, ref value); - if (oldValue != value) - { - _bChildOptional = value; - } - } - } + public virtual global::Testing.BChild BChildOptional { get; set; } } } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/BParentOptional.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/BParentOptional.generated.cs index 806647949..0133d5bbb 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/BParentOptional.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/BParentOptional.generated.cs @@ -50,9 +50,9 @@ public BParentOptional(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; + bchildrequired.BParentOptional = this; this.BChildCollection = new System.Collections.ObjectModel.ObservableCollection(); - Init(); } @@ -69,108 +69,25 @@ public static BParentOptional Create(global::Testing.BChild bchildrequired) * Properties *************************************************************************/ - /// - /// Backing field for Id - /// - internal int _id; - /// - /// When provided in a partial class, allows value of Id to be changed before setting. - /// - partial void SetId(int oldValue, ref int newValue); - /// - /// When provided in a partial class, allows value of Id to be changed before returning. - /// - partial void GetId(ref int result); - /// /// Identity, Indexed, Required /// [Key] [Required] - public int Id - { - get - { - int value = _id; - GetId(ref value); - return (_id = value); - } - protected set - { - int oldValue = _id; - SetId(oldValue, ref value); - if (oldValue != value) - { - _id = value; - } - } - } + public int Id { get; set; } /************************************************************************* * Navigation properties *************************************************************************/ - protected global::Testing.BChild _bChildRequired; - partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); - partial void GetBChildRequired(ref global::Testing.BChild result); - /// /// Required /// - public virtual global::Testing.BChild BChildRequired - { - get - { - global::Testing.BChild value = _bChildRequired; - GetBChildRequired(ref value); - return (_bChildRequired = value); - } - set - { - global::Testing.BChild oldValue = _bChildRequired; - SetBChildRequired(oldValue, ref value); - if (oldValue != value) - { - _bChildRequired = value; - } - } - } + public virtual global::Testing.BChild BChildRequired { get; set; } - protected ICollection _bChildCollection; - public virtual ICollection BChildCollection - { - get - { - return _bChildCollection; - } - private set - { - _bChildCollection = value; - } - } - - protected global::Testing.BChild _bChildOptional; - partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); - partial void GetBChildOptional(ref global::Testing.BChild result); + public virtual ICollection BChildCollection { get; private set; } - public virtual global::Testing.BChild BChildOptional - { - get - { - global::Testing.BChild value = _bChildOptional; - GetBChildOptional(ref value); - return (_bChildOptional = value); - } - set - { - global::Testing.BChild oldValue = _bChildOptional; - SetBChildOptional(oldValue, ref value); - if (oldValue != value) - { - _bChildOptional = value; - } - } - } + public virtual global::Testing.BChild BChildOptional { get; set; } } } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/BParentRequired.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/BParentRequired.generated.cs index 12f9a0c02..82fa40d65 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/BParentRequired.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/BParentRequired.generated.cs @@ -38,108 +38,25 @@ public BParentRequired() * Properties *************************************************************************/ - /// - /// Backing field for Id - /// - internal int _id; - /// - /// When provided in a partial class, allows value of Id to be changed before setting. - /// - partial void SetId(int oldValue, ref int newValue); - /// - /// When provided in a partial class, allows value of Id to be changed before returning. - /// - partial void GetId(ref int result); - /// /// Identity, Indexed, Required /// [Key] [Required] - public int Id - { - get - { - int value = _id; - GetId(ref value); - return (_id = value); - } - protected set - { - int oldValue = _id; - SetId(oldValue, ref value); - if (oldValue != value) - { - _id = value; - } - } - } + public int Id { get; set; } /************************************************************************* * Navigation properties *************************************************************************/ - protected global::Testing.BChild _bChildOptional; - partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); - partial void GetBChildOptional(ref global::Testing.BChild result); - - public virtual global::Testing.BChild BChildOptional - { - get - { - global::Testing.BChild value = _bChildOptional; - GetBChildOptional(ref value); - return (_bChildOptional = value); - } - set - { - global::Testing.BChild oldValue = _bChildOptional; - SetBChildOptional(oldValue, ref value); - if (oldValue != value) - { - _bChildOptional = value; - } - } - } - - protected global::Testing.BChild _bChildRequired; - partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); - partial void GetBChildRequired(ref global::Testing.BChild result); + public virtual global::Testing.BChild BChildOptional { get; set; } /// /// Required /// - public virtual global::Testing.BChild BChildRequired - { - get - { - global::Testing.BChild value = _bChildRequired; - GetBChildRequired(ref value); - return (_bChildRequired = value); - } - set - { - global::Testing.BChild oldValue = _bChildRequired; - SetBChildRequired(oldValue, ref value); - if (oldValue != value) - { - _bChildRequired = value; - } - } - } + public virtual global::Testing.BChild BChildRequired { get; set; } - protected ICollection _bChildCollection; - public virtual ICollection BChildCollection - { - get - { - return _bChildCollection; - } - private set - { - _bChildCollection = value; - } - } + public virtual ICollection BChildCollection { get; private set; } } } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/BaseClass.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/BaseClass.generated.cs index d5d203554..4bc2c5c1c 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/BaseClass.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/BaseClass.generated.cs @@ -48,7 +48,6 @@ public BaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/BaseClassWithRequiredProperties.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/BaseClassWithRequiredProperties.generated.cs index ede9bbf22..069852ebd 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/BaseClassWithRequiredProperties.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/BaseClassWithRequiredProperties.generated.cs @@ -48,7 +48,6 @@ public BaseClassWithRequiredProperties(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } @@ -65,78 +64,18 @@ public static BaseClassWithRequiredProperties Create(string property0) * Properties *************************************************************************/ - /// - /// Backing field for Id - /// - internal int _id; - /// - /// When provided in a partial class, allows value of Id to be changed before setting. - /// - partial void SetId(int oldValue, ref int newValue); - /// - /// When provided in a partial class, allows value of Id to be changed before returning. - /// - partial void GetId(ref int result); - /// /// Identity, Indexed, Required /// [Key] [Required] - public int Id - { - get - { - int value = _id; - GetId(ref value); - return (_id = value); - } - protected set - { - int oldValue = _id; - SetId(oldValue, ref value); - if (oldValue != value) - { - _id = value; - } - } - } - - /// - /// Backing field for Property0 - /// - protected string _property0; - /// - /// When provided in a partial class, allows value of Property0 to be changed before setting. - /// - partial void SetProperty0(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of Property0 to be changed before returning. - /// - partial void GetProperty0(ref string result); + public int Id { get; set; } /// /// Required /// [Required] - public string Property0 - { - get - { - string value = _property0; - GetProperty0(ref value); - return (_property0 = value); - } - set - { - string oldValue = _property0; - SetProperty0(oldValue, ref value); - if (oldValue != value) - { - _property0 = value; - } - } - } + public string Property0 { get; set; } } } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/Child.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/Child.generated.cs index efc217ead..7bade1ed7 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/Child.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/Child.generated.cs @@ -51,12 +51,12 @@ public Child(global::Testing.Child parent, global::Testing.Master _master0) { if (parent == null) throw new ArgumentNullException(nameof(parent)); this.Parent = parent; + parent.Children.Add(this); if (_master0 == null) throw new ArgumentNullException(nameof(_master0)); _master0.Children.Add(this); this.Children = new System.Collections.ObjectModel.ObservableCollection(); - Init(); } @@ -74,85 +74,23 @@ public static Child Create(global::Testing.Child parent, global::Testing.Master * Properties *************************************************************************/ - /// - /// Backing field for Id - /// - internal int _id; - /// - /// When provided in a partial class, allows value of Id to be changed before setting. - /// - partial void SetId(int oldValue, ref int newValue); - /// - /// When provided in a partial class, allows value of Id to be changed before returning. - /// - partial void GetId(ref int result); - /// /// Identity, Indexed, Required /// [Key] [Required] - public int Id - { - get - { - int value = _id; - GetId(ref value); - return (_id = value); - } - protected set - { - int oldValue = _id; - SetId(oldValue, ref value); - if (oldValue != value) - { - _id = value; - } - } - } + public int Id { get; set; } /************************************************************************* * Navigation properties *************************************************************************/ - protected ICollection _children; - public virtual ICollection Children - { - get - { - return _children; - } - private set - { - _children = value; - } - } - - protected global::Testing.Child _parent; - partial void SetParent(global::Testing.Child oldValue, ref global::Testing.Child newValue); - partial void GetParent(ref global::Testing.Child result); + public virtual ICollection Children { get; private set; } /// /// Required /// - public virtual global::Testing.Child Parent - { - get - { - global::Testing.Child value = _parent; - GetParent(ref value); - return (_parent = value); - } - set - { - global::Testing.Child oldValue = _parent; - SetParent(oldValue, ref value); - if (oldValue != value) - { - _parent = value; - } - } - } + public virtual global::Testing.Child Parent { get; set; } } } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/ConcreteDerivedClass.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/ConcreteDerivedClass.generated.cs index d8e84122f..d263a39e9 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/ConcreteDerivedClass.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/ConcreteDerivedClass.generated.cs @@ -48,7 +48,6 @@ public ConcreteDerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } @@ -65,69 +64,9 @@ public ConcreteDerivedClass(string property0) * Properties *************************************************************************/ - /// - /// Backing field for Property1 - /// - protected string _property1; - /// - /// When provided in a partial class, allows value of Property1 to be changed before setting. - /// - partial void SetProperty1(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of Property1 to be changed before returning. - /// - partial void GetProperty1(ref string result); - - public string Property1 - { - get - { - string value = _property1; - GetProperty1(ref value); - return (_property1 = value); - } - set - { - string oldValue = _property1; - SetProperty1(oldValue, ref value); - if (oldValue != value) - { - _property1 = value; - } - } - } + public string Property1 { get; set; } - /// - /// Backing field for PropertyInChild - /// - protected string _propertyInChild; - /// - /// When provided in a partial class, allows value of PropertyInChild to be changed before setting. - /// - partial void SetPropertyInChild(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of PropertyInChild to be changed before returning. - /// - partial void GetPropertyInChild(ref string result); - - public string PropertyInChild - { - get - { - string value = _propertyInChild; - GetPropertyInChild(ref value); - return (_propertyInChild = value); - } - set - { - string oldValue = _propertyInChild; - SetPropertyInChild(oldValue, ref value); - if (oldValue != value) - { - _propertyInChild = value; - } - } - } + public string PropertyInChild { get; set; } } } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs index e69317163..06f1add61 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs @@ -52,7 +52,6 @@ public ConcreteDerivedClassWithRequiredProperties(string property1, string prope if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } @@ -70,41 +69,11 @@ public static ConcreteDerivedClassWithRequiredProperties Create(string property1 * Properties *************************************************************************/ - /// - /// Backing field for Property1 - /// - protected string _property1; - /// - /// When provided in a partial class, allows value of Property1 to be changed before setting. - /// - partial void SetProperty1(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of Property1 to be changed before returning. - /// - partial void GetProperty1(ref string result); - /// /// Required /// [Required] - public string Property1 - { - get - { - string value = _property1; - GetProperty1(ref value); - return (_property1 = value); - } - set - { - string oldValue = _property1; - SetProperty1(oldValue, ref value); - if (oldValue != value) - { - _property1 = value; - } - } - } + public string Property1 { get; set; } } } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/DerivedClass.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/DerivedClass.generated.cs index 26776231a..a9e3f91e3 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/DerivedClass.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/DerivedClass.generated.cs @@ -48,7 +48,6 @@ public DerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } @@ -65,69 +64,9 @@ public DerivedClass(string property0) * Properties *************************************************************************/ - /// - /// Backing field for Property1 - /// - protected string _property1; - /// - /// When provided in a partial class, allows value of Property1 to be changed before setting. - /// - partial void SetProperty1(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of Property1 to be changed before returning. - /// - partial void GetProperty1(ref string result); - - public string Property1 - { - get - { - string value = _property1; - GetProperty1(ref value); - return (_property1 = value); - } - set - { - string oldValue = _property1; - SetProperty1(oldValue, ref value); - if (oldValue != value) - { - _property1 = value; - } - } - } + public string Property1 { get; set; } - /// - /// Backing field for PropertyInChild - /// - protected string _propertyInChild; - /// - /// When provided in a partial class, allows value of PropertyInChild to be changed before setting. - /// - partial void SetPropertyInChild(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of PropertyInChild to be changed before returning. - /// - partial void GetPropertyInChild(ref string result); - - public string PropertyInChild - { - get - { - string value = _propertyInChild; - GetPropertyInChild(ref value); - return (_propertyInChild = value); - } - set - { - string oldValue = _propertyInChild; - SetPropertyInChild(oldValue, ref value); - if (oldValue != value) - { - _propertyInChild = value; - } - } - } + public string PropertyInChild { get; set; } } } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/HiddenEntity.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/HiddenEntity.generated.cs index 0568e94fe..483ecdb8b 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/HiddenEntity.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/HiddenEntity.generated.cs @@ -35,42 +35,12 @@ protected HiddenEntity() * Properties *************************************************************************/ - /// - /// Backing field for Id - /// - internal int _id; - /// - /// When provided in a partial class, allows value of Id to be changed before setting. - /// - partial void SetId(int oldValue, ref int newValue); - /// - /// When provided in a partial class, allows value of Id to be changed before returning. - /// - partial void GetId(ref int result); - /// /// Identity, Indexed, Required /// [Key] [Required] - public int Id - { - get - { - int value = _id; - GetId(ref value); - return (_id = value); - } - protected set - { - int oldValue = _id; - SetId(oldValue, ref value); - if (oldValue != value) - { - _id = value; - } - } - } + public int Id { get; set; } } } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/Master.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/Master.generated.cs index 2ae49defd..b525e09c5 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/Master.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/Master.generated.cs @@ -37,59 +37,18 @@ public Master() * Properties *************************************************************************/ - /// - /// Backing field for Id - /// - internal int _id; - /// - /// When provided in a partial class, allows value of Id to be changed before setting. - /// - partial void SetId(int oldValue, ref int newValue); - /// - /// When provided in a partial class, allows value of Id to be changed before returning. - /// - partial void GetId(ref int result); - /// /// Identity, Indexed, Required /// [Key] [Required] - public int Id - { - get - { - int value = _id; - GetId(ref value); - return (_id = value); - } - protected set - { - int oldValue = _id; - SetId(oldValue, ref value); - if (oldValue != value) - { - _id = value; - } - } - } + public int Id { get; set; } /************************************************************************* * Navigation properties *************************************************************************/ - protected ICollection _children; - public virtual ICollection Children - { - get - { - return _children; - } - private set - { - _children = value; - } - } + public virtual ICollection Children { get; private set; } } } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/ParserTest.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/ParserTest.generated.cs index 9538d5ba2..4df4c3ecb 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/ParserTest.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/ParserTest.generated.cs @@ -47,7 +47,6 @@ public ParserTest(long foo) { this.foo = foo; - Init(); } @@ -64,654 +63,54 @@ public static ParserTest Create(long foo) * Properties *************************************************************************/ - /// - /// Backing field for Id - /// - protected int _id; - /// - /// When provided in a partial class, allows value of Id to be changed before setting. - /// - partial void SetId(int oldValue, ref int newValue); - /// - /// When provided in a partial class, allows value of Id to be changed before returning. - /// - partial void GetId(ref int result); - /// /// Identity, Required /// [Key] [Required] - public int Id - { - get - { - int value = _id; - GetId(ref value); - return (_id = value); - } - protected set - { - int oldValue = _id; - SetId(oldValue, ref value); - if (oldValue != value) - { - _id = value; - } - } - } - - /// - /// Backing field for foo - /// - protected long _foo; - /// - /// When provided in a partial class, allows value of foo to be changed before setting. - /// - partial void Setfoo(long oldValue, ref long newValue); - /// - /// When provided in a partial class, allows value of foo to be changed before returning. - /// - partial void Getfoo(ref long result); + public int Id { get; set; } /// /// Required /// [Required] - public long foo - { - get - { - long value = _foo; - Getfoo(ref value); - return (_foo = value); - } - set - { - long oldValue = _foo; - Setfoo(oldValue, ref value); - if (oldValue != value) - { - _foo = value; - } - } - } + public long foo { get; set; } - /// - /// Backing field for name1 - /// - protected string _name1; - /// - /// When provided in a partial class, allows value of name1 to be changed before setting. - /// - partial void Setname1(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of name1 to be changed before returning. - /// - partial void Getname1(ref string result); + public string name1 { get; set; } - public string name1 - { - get - { - string value = _name1; - Getname1(ref value); - return (_name1 = value); - } - set - { - string oldValue = _name1; - Setname1(oldValue, ref value); - if (oldValue != value) - { - _name1 = value; - } - } - } + public string name2 { get; protected set; } - /// - /// Backing field for name2 - /// - protected string _name2; - /// - /// When provided in a partial class, allows value of name2 to be changed before setting. - /// - partial void Setname2(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of name2 to be changed before returning. - /// - partial void Getname2(ref string result); + public int? name3 { get; set; } - public string name2 - { - get - { - string value = _name2; - Getname2(ref value); - return (_name2 = value); - } - protected set - { - string oldValue = _name2; - Setname2(oldValue, ref value); - if (oldValue != value) - { - _name2 = value; - } - } - } + public int? name4 { get; protected set; } - /// - /// Backing field for name3 - /// - protected int? _name3; - /// - /// When provided in a partial class, allows value of name3 to be changed before setting. - /// - partial void Setname3(int? oldValue, ref int? newValue); - /// - /// When provided in a partial class, allows value of name3 to be changed before returning. - /// - partial void Getname3(ref int? result); + public int? name5 { get; set; } - public int? name3 - { - get - { - int? value = _name3; - Getname3(ref value); - return (_name3 = value); - } - set - { - int? oldValue = _name3; - Setname3(oldValue, ref value); - if (oldValue != value) - { - _name3 = value; - } - } - } + public int? name6 { get; protected set; } - /// - /// Backing field for name4 - /// - protected int? _name4; - /// - /// When provided in a partial class, allows value of name4 to be changed before setting. - /// - partial void Setname4(int? oldValue, ref int? newValue); - /// - /// When provided in a partial class, allows value of name4 to be changed before returning. - /// - partial void Getname4(ref int? result); + public string name7 { get; set; } - public int? name4 - { - get - { - int? value = _name4; - Getname4(ref value); - return (_name4 = value); - } - protected set - { - int? oldValue = _name4; - Setname4(oldValue, ref value); - if (oldValue != value) - { - _name4 = value; - } - } - } + public string name8 { get; protected set; } - /// - /// Backing field for name5 - /// - protected int? _name5; - /// - /// When provided in a partial class, allows value of name5 to be changed before setting. - /// - partial void Setname5(int? oldValue, ref int? newValue); - /// - /// When provided in a partial class, allows value of name5 to be changed before returning. - /// - partial void Getname5(ref int? result); + public string name9 { get; set; } - public int? name5 - { - get - { - int? value = _name5; - Getname5(ref value); - return (_name5 = value); - } - set - { - int? oldValue = _name5; - Setname5(oldValue, ref value); - if (oldValue != value) - { - _name5 = value; - } - } - } + public string name { get; protected set; } - /// - /// Backing field for name6 - /// - protected int? _name6; - /// - /// When provided in a partial class, allows value of name6 to be changed before setting. - /// - partial void Setname6(int? oldValue, ref int? newValue); - /// - /// When provided in a partial class, allows value of name6 to be changed before returning. - /// - partial void Getname6(ref int? result); + public int? name11 { get; set; } - public int? name6 - { - get - { - int? value = _name6; - Getname6(ref value); - return (_name6 = value); - } - protected set - { - int? oldValue = _name6; - Setname6(oldValue, ref value); - if (oldValue != value) - { - _name6 = value; - } - } - } + public int? name12 { get; protected set; } - /// - /// Backing field for name7 - /// - protected string _name7; - /// - /// When provided in a partial class, allows value of name7 to be changed before setting. - /// - partial void Setname7(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of name7 to be changed before returning. - /// - partial void Getname7(ref string result); + public int? name13 { get; set; } - public string name7 - { - get - { - string value = _name7; - Getname7(ref value); - return (_name7 = value); - } - set - { - string oldValue = _name7; - Setname7(oldValue, ref value); - if (oldValue != value) - { - _name7 = value; - } - } - } + public int? name14 { get; protected set; } - /// - /// Backing field for name8 - /// - protected string _name8; - /// - /// When provided in a partial class, allows value of name8 to be changed before setting. - /// - partial void Setname8(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of name8 to be changed before returning. - /// - partial void Getname8(ref string result); + public string name15 { get; set; } - public string name8 - { - get - { - string value = _name8; - Getname8(ref value); - return (_name8 = value); - } - protected set - { - string oldValue = _name8; - Setname8(oldValue, ref value); - if (oldValue != value) - { - _name8 = value; - } - } - } + public string name16 { get; protected set; } - /// - /// Backing field for name9 - /// - protected string _name9; - /// - /// When provided in a partial class, allows value of name9 to be changed before setting. - /// - partial void Setname9(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of name9 to be changed before returning. - /// - partial void Getname9(ref string result); + public string name17 { get; set; } - public string name9 - { - get - { - string value = _name9; - Getname9(ref value); - return (_name9 = value); - } - set - { - string oldValue = _name9; - Setname9(oldValue, ref value); - if (oldValue != value) - { - _name9 = value; - } - } - } - - /// - /// Backing field for name - /// - protected string _name; - /// - /// When provided in a partial class, allows value of name to be changed before setting. - /// - partial void Setname(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of name to be changed before returning. - /// - partial void Getname(ref string result); - - public string name - { - get - { - string value = _name; - Getname(ref value); - return (_name = value); - } - protected set - { - string oldValue = _name; - Setname(oldValue, ref value); - if (oldValue != value) - { - _name = value; - } - } - } - - /// - /// Backing field for name11 - /// - protected int? _name11; - /// - /// When provided in a partial class, allows value of name11 to be changed before setting. - /// - partial void Setname11(int? oldValue, ref int? newValue); - /// - /// When provided in a partial class, allows value of name11 to be changed before returning. - /// - partial void Getname11(ref int? result); - - public int? name11 - { - get - { - int? value = _name11; - Getname11(ref value); - return (_name11 = value); - } - set - { - int? oldValue = _name11; - Setname11(oldValue, ref value); - if (oldValue != value) - { - _name11 = value; - } - } - } - - /// - /// Backing field for name12 - /// - protected int? _name12; - /// - /// When provided in a partial class, allows value of name12 to be changed before setting. - /// - partial void Setname12(int? oldValue, ref int? newValue); - /// - /// When provided in a partial class, allows value of name12 to be changed before returning. - /// - partial void Getname12(ref int? result); - - public int? name12 - { - get - { - int? value = _name12; - Getname12(ref value); - return (_name12 = value); - } - protected set - { - int? oldValue = _name12; - Setname12(oldValue, ref value); - if (oldValue != value) - { - _name12 = value; - } - } - } - - /// - /// Backing field for name13 - /// - protected int? _name13; - /// - /// When provided in a partial class, allows value of name13 to be changed before setting. - /// - partial void Setname13(int? oldValue, ref int? newValue); - /// - /// When provided in a partial class, allows value of name13 to be changed before returning. - /// - partial void Getname13(ref int? result); - - public int? name13 - { - get - { - int? value = _name13; - Getname13(ref value); - return (_name13 = value); - } - set - { - int? oldValue = _name13; - Setname13(oldValue, ref value); - if (oldValue != value) - { - _name13 = value; - } - } - } - - /// - /// Backing field for name14 - /// - protected int? _name14; - /// - /// When provided in a partial class, allows value of name14 to be changed before setting. - /// - partial void Setname14(int? oldValue, ref int? newValue); - /// - /// When provided in a partial class, allows value of name14 to be changed before returning. - /// - partial void Getname14(ref int? result); - - public int? name14 - { - get - { - int? value = _name14; - Getname14(ref value); - return (_name14 = value); - } - protected set - { - int? oldValue = _name14; - Setname14(oldValue, ref value); - if (oldValue != value) - { - _name14 = value; - } - } - } - - /// - /// Backing field for name15 - /// - protected string _name15; - /// - /// When provided in a partial class, allows value of name15 to be changed before setting. - /// - partial void Setname15(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of name15 to be changed before returning. - /// - partial void Getname15(ref string result); - - public string name15 - { - get - { - string value = _name15; - Getname15(ref value); - return (_name15 = value); - } - set - { - string oldValue = _name15; - Setname15(oldValue, ref value); - if (oldValue != value) - { - _name15 = value; - } - } - } - - /// - /// Backing field for name16 - /// - protected string _name16; - /// - /// When provided in a partial class, allows value of name16 to be changed before setting. - /// - partial void Setname16(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of name16 to be changed before returning. - /// - partial void Getname16(ref string result); - - public string name16 - { - get - { - string value = _name16; - Getname16(ref value); - return (_name16 = value); - } - protected set - { - string oldValue = _name16; - Setname16(oldValue, ref value); - if (oldValue != value) - { - _name16 = value; - } - } - } - - /// - /// Backing field for name17 - /// - protected string _name17; - /// - /// When provided in a partial class, allows value of name17 to be changed before setting. - /// - partial void Setname17(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of name17 to be changed before returning. - /// - partial void Getname17(ref string result); - - public string name17 - { - get - { - string value = _name17; - Getname17(ref value); - return (_name17 = value); - } - set - { - string oldValue = _name17; - Setname17(oldValue, ref value); - if (oldValue != value) - { - _name17 = value; - } - } - } - - /// - /// Backing field for name18 - /// - protected string _name18; - /// - /// When provided in a partial class, allows value of name18 to be changed before setting. - /// - partial void Setname18(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of name18 to be changed before returning. - /// - partial void Getname18(ref string result); - - public string name18 - { - get - { - string value = _name18; - Getname18(ref value); - return (_name18 = value); - } - protected set - { - string oldValue = _name18; - Setname18(oldValue, ref value); - if (oldValue != value) - { - _name18 = value; - } - } - } + public string name18 { get; protected set; } } } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/RenamedColumn.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/RenamedColumn.generated.cs index d39ea6ec6..dc4dd2fc1 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/RenamedColumn.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/RenamedColumn.generated.cs @@ -35,42 +35,12 @@ public RenamedColumn() * Properties *************************************************************************/ - /// - /// Backing field for Id - /// - internal int _id; - /// - /// When provided in a partial class, allows value of Id to be changed before setting. - /// - partial void SetId(int oldValue, ref int newValue); - /// - /// When provided in a partial class, allows value of Id to be changed before returning. - /// - partial void GetId(ref int result); - /// /// Identity, Indexed, Required /// [Key] [Required] - public int Id - { - get - { - int value = _id; - GetId(ref value); - return (_id = value); - } - protected set - { - int oldValue = _id; - SetId(oldValue, ref value); - if (oldValue != value) - { - _id = value; - } - } - } + public int Id { get; set; } } } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/SpatialProperties.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/SpatialProperties.generated.cs index 8923c5cbf..c7d2e3c1a 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/SpatialProperties.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/SpatialProperties.generated.cs @@ -104,7 +104,6 @@ public SpatialProperties(DbGeography attrgeography, DbGeography attrgeographycol if (attrgeometrypoint == null) throw new ArgumentNullException(nameof(attrgeometrypoint)); this.AttrGeometryPoint = attrgeometrypoint; - Init(); } @@ -135,582 +134,102 @@ public static SpatialProperties Create(DbGeography attrgeography, DbGeography at * Properties *************************************************************************/ - /// - /// Backing field for Id - /// - protected int _id; - /// - /// When provided in a partial class, allows value of Id to be changed before setting. - /// - partial void SetId(int oldValue, ref int newValue); - /// - /// When provided in a partial class, allows value of Id to be changed before returning. - /// - partial void GetId(ref int result); - /// /// Identity, Required /// [Key] [Required] - public int Id - { - get - { - int value = _id; - GetId(ref value); - return (_id = value); - } - protected set - { - int oldValue = _id; - SetId(oldValue, ref value); - if (oldValue != value) - { - _id = value; - } - } - } - - /// - /// Backing field for AttrGeography - /// - protected DbGeography _attrGeography; - /// - /// When provided in a partial class, allows value of AttrGeography to be changed before setting. - /// - partial void SetAttrGeography(DbGeography oldValue, ref DbGeography newValue); - /// - /// When provided in a partial class, allows value of AttrGeography to be changed before returning. - /// - partial void GetAttrGeography(ref DbGeography result); + public int Id { get; set; } /// /// Required /// [Required] - public DbGeography AttrGeography - { - get - { - DbGeography value = _attrGeography; - GetAttrGeography(ref value); - return (_attrGeography = value); - } - set - { - DbGeography oldValue = _attrGeography; - SetAttrGeography(oldValue, ref value); - if (oldValue != value) - { - _attrGeography = value; - } - } - } - - /// - /// Backing field for AttrGeographyCollection - /// - protected DbGeography _attrGeographyCollection; - /// - /// When provided in a partial class, allows value of AttrGeographyCollection to be changed before setting. - /// - partial void SetAttrGeographyCollection(DbGeography oldValue, ref DbGeography newValue); - /// - /// When provided in a partial class, allows value of AttrGeographyCollection to be changed before returning. - /// - partial void GetAttrGeographyCollection(ref DbGeography result); + public DbGeography AttrGeography { get; set; } /// /// Required /// [Required] - public DbGeography AttrGeographyCollection - { - get - { - DbGeography value = _attrGeographyCollection; - GetAttrGeographyCollection(ref value); - return (_attrGeographyCollection = value); - } - set - { - DbGeography oldValue = _attrGeographyCollection; - SetAttrGeographyCollection(oldValue, ref value); - if (oldValue != value) - { - _attrGeographyCollection = value; - } - } - } - - /// - /// Backing field for AttrGeographyLineString - /// - protected DbGeography _attrGeographyLineString; - /// - /// When provided in a partial class, allows value of AttrGeographyLineString to be changed before setting. - /// - partial void SetAttrGeographyLineString(DbGeography oldValue, ref DbGeography newValue); - /// - /// When provided in a partial class, allows value of AttrGeographyLineString to be changed before returning. - /// - partial void GetAttrGeographyLineString(ref DbGeography result); + public DbGeography AttrGeographyCollection { get; set; } /// /// Required /// [Required] - public DbGeography AttrGeographyLineString - { - get - { - DbGeography value = _attrGeographyLineString; - GetAttrGeographyLineString(ref value); - return (_attrGeographyLineString = value); - } - set - { - DbGeography oldValue = _attrGeographyLineString; - SetAttrGeographyLineString(oldValue, ref value); - if (oldValue != value) - { - _attrGeographyLineString = value; - } - } - } - - /// - /// Backing field for AttrGeographyMultiLineString - /// - protected DbGeography _attrGeographyMultiLineString; - /// - /// When provided in a partial class, allows value of AttrGeographyMultiLineString to be changed before setting. - /// - partial void SetAttrGeographyMultiLineString(DbGeography oldValue, ref DbGeography newValue); - /// - /// When provided in a partial class, allows value of AttrGeographyMultiLineString to be changed before returning. - /// - partial void GetAttrGeographyMultiLineString(ref DbGeography result); + public DbGeography AttrGeographyLineString { get; set; } /// /// Required /// [Required] - public DbGeography AttrGeographyMultiLineString - { - get - { - DbGeography value = _attrGeographyMultiLineString; - GetAttrGeographyMultiLineString(ref value); - return (_attrGeographyMultiLineString = value); - } - set - { - DbGeography oldValue = _attrGeographyMultiLineString; - SetAttrGeographyMultiLineString(oldValue, ref value); - if (oldValue != value) - { - _attrGeographyMultiLineString = value; - } - } - } - - /// - /// Backing field for AttrGeographyMultiPoint - /// - protected DbGeography _attrGeographyMultiPoint; - /// - /// When provided in a partial class, allows value of AttrGeographyMultiPoint to be changed before setting. - /// - partial void SetAttrGeographyMultiPoint(DbGeography oldValue, ref DbGeography newValue); - /// - /// When provided in a partial class, allows value of AttrGeographyMultiPoint to be changed before returning. - /// - partial void GetAttrGeographyMultiPoint(ref DbGeography result); + public DbGeography AttrGeographyMultiLineString { get; set; } /// /// Required /// [Required] - public DbGeography AttrGeographyMultiPoint - { - get - { - DbGeography value = _attrGeographyMultiPoint; - GetAttrGeographyMultiPoint(ref value); - return (_attrGeographyMultiPoint = value); - } - set - { - DbGeography oldValue = _attrGeographyMultiPoint; - SetAttrGeographyMultiPoint(oldValue, ref value); - if (oldValue != value) - { - _attrGeographyMultiPoint = value; - } - } - } - - /// - /// Backing field for AttrGeographyMultiPolygon - /// - protected DbGeography _attrGeographyMultiPolygon; - /// - /// When provided in a partial class, allows value of AttrGeographyMultiPolygon to be changed before setting. - /// - partial void SetAttrGeographyMultiPolygon(DbGeography oldValue, ref DbGeography newValue); - /// - /// When provided in a partial class, allows value of AttrGeographyMultiPolygon to be changed before returning. - /// - partial void GetAttrGeographyMultiPolygon(ref DbGeography result); + public DbGeography AttrGeographyMultiPoint { get; set; } /// /// Required /// [Required] - public DbGeography AttrGeographyMultiPolygon - { - get - { - DbGeography value = _attrGeographyMultiPolygon; - GetAttrGeographyMultiPolygon(ref value); - return (_attrGeographyMultiPolygon = value); - } - set - { - DbGeography oldValue = _attrGeographyMultiPolygon; - SetAttrGeographyMultiPolygon(oldValue, ref value); - if (oldValue != value) - { - _attrGeographyMultiPolygon = value; - } - } - } - - /// - /// Backing field for AttrGeographyPoint - /// - protected DbGeography _attrGeographyPoint; - /// - /// When provided in a partial class, allows value of AttrGeographyPoint to be changed before setting. - /// - partial void SetAttrGeographyPoint(DbGeography oldValue, ref DbGeography newValue); - /// - /// When provided in a partial class, allows value of AttrGeographyPoint to be changed before returning. - /// - partial void GetAttrGeographyPoint(ref DbGeography result); + public DbGeography AttrGeographyMultiPolygon { get; set; } /// /// Required /// [Required] - public DbGeography AttrGeographyPoint - { - get - { - DbGeography value = _attrGeographyPoint; - GetAttrGeographyPoint(ref value); - return (_attrGeographyPoint = value); - } - set - { - DbGeography oldValue = _attrGeographyPoint; - SetAttrGeographyPoint(oldValue, ref value); - if (oldValue != value) - { - _attrGeographyPoint = value; - } - } - } - - /// - /// Backing field for AttrGeographyPolygon - /// - protected DbGeography _attrGeographyPolygon; - /// - /// When provided in a partial class, allows value of AttrGeographyPolygon to be changed before setting. - /// - partial void SetAttrGeographyPolygon(DbGeography oldValue, ref DbGeography newValue); - /// - /// When provided in a partial class, allows value of AttrGeographyPolygon to be changed before returning. - /// - partial void GetAttrGeographyPolygon(ref DbGeography result); + public DbGeography AttrGeographyPoint { get; set; } /// /// Required /// [Required] - public DbGeography AttrGeographyPolygon - { - get - { - DbGeography value = _attrGeographyPolygon; - GetAttrGeographyPolygon(ref value); - return (_attrGeographyPolygon = value); - } - set - { - DbGeography oldValue = _attrGeographyPolygon; - SetAttrGeographyPolygon(oldValue, ref value); - if (oldValue != value) - { - _attrGeographyPolygon = value; - } - } - } - - /// - /// Backing field for AttrGeometry - /// - protected DbGeometry _attrGeometry; - /// - /// When provided in a partial class, allows value of AttrGeometry to be changed before setting. - /// - partial void SetAttrGeometry(DbGeometry oldValue, ref DbGeometry newValue); - /// - /// When provided in a partial class, allows value of AttrGeometry to be changed before returning. - /// - partial void GetAttrGeometry(ref DbGeometry result); + public DbGeography AttrGeographyPolygon { get; set; } /// /// Required /// [Required] - public DbGeometry AttrGeometry - { - get - { - DbGeometry value = _attrGeometry; - GetAttrGeometry(ref value); - return (_attrGeometry = value); - } - set - { - DbGeometry oldValue = _attrGeometry; - SetAttrGeometry(oldValue, ref value); - if (oldValue != value) - { - _attrGeometry = value; - } - } - } - - /// - /// Backing field for AttrGeometryCollection - /// - protected DbGeometry _attrGeometryCollection; - /// - /// When provided in a partial class, allows value of AttrGeometryCollection to be changed before setting. - /// - partial void SetAttrGeometryCollection(DbGeometry oldValue, ref DbGeometry newValue); - /// - /// When provided in a partial class, allows value of AttrGeometryCollection to be changed before returning. - /// - partial void GetAttrGeometryCollection(ref DbGeometry result); + public DbGeometry AttrGeometry { get; set; } /// /// Required /// [Required] - public DbGeometry AttrGeometryCollection - { - get - { - DbGeometry value = _attrGeometryCollection; - GetAttrGeometryCollection(ref value); - return (_attrGeometryCollection = value); - } - set - { - DbGeometry oldValue = _attrGeometryCollection; - SetAttrGeometryCollection(oldValue, ref value); - if (oldValue != value) - { - _attrGeometryCollection = value; - } - } - } - - /// - /// Backing field for AttrGeometryLineString - /// - protected DbGeometry _attrGeometryLineString; - /// - /// When provided in a partial class, allows value of AttrGeometryLineString to be changed before setting. - /// - partial void SetAttrGeometryLineString(DbGeometry oldValue, ref DbGeometry newValue); - /// - /// When provided in a partial class, allows value of AttrGeometryLineString to be changed before returning. - /// - partial void GetAttrGeometryLineString(ref DbGeometry result); + public DbGeometry AttrGeometryCollection { get; set; } /// /// Required /// [Required] - public DbGeometry AttrGeometryLineString - { - get - { - DbGeometry value = _attrGeometryLineString; - GetAttrGeometryLineString(ref value); - return (_attrGeometryLineString = value); - } - set - { - DbGeometry oldValue = _attrGeometryLineString; - SetAttrGeometryLineString(oldValue, ref value); - if (oldValue != value) - { - _attrGeometryLineString = value; - } - } - } - - /// - /// Backing field for AttrGeometryMultiLineString - /// - protected DbGeometry _attrGeometryMultiLineString; - /// - /// When provided in a partial class, allows value of AttrGeometryMultiLineString to be changed before setting. - /// - partial void SetAttrGeometryMultiLineString(DbGeometry oldValue, ref DbGeometry newValue); - /// - /// When provided in a partial class, allows value of AttrGeometryMultiLineString to be changed before returning. - /// - partial void GetAttrGeometryMultiLineString(ref DbGeometry result); + public DbGeometry AttrGeometryLineString { get; set; } /// /// Required /// [Required] - public DbGeometry AttrGeometryMultiLineString - { - get - { - DbGeometry value = _attrGeometryMultiLineString; - GetAttrGeometryMultiLineString(ref value); - return (_attrGeometryMultiLineString = value); - } - set - { - DbGeometry oldValue = _attrGeometryMultiLineString; - SetAttrGeometryMultiLineString(oldValue, ref value); - if (oldValue != value) - { - _attrGeometryMultiLineString = value; - } - } - } - - /// - /// Backing field for AttrGeometryMultiPoint - /// - protected DbGeometry _attrGeometryMultiPoint; - /// - /// When provided in a partial class, allows value of AttrGeometryMultiPoint to be changed before setting. - /// - partial void SetAttrGeometryMultiPoint(DbGeometry oldValue, ref DbGeometry newValue); - /// - /// When provided in a partial class, allows value of AttrGeometryMultiPoint to be changed before returning. - /// - partial void GetAttrGeometryMultiPoint(ref DbGeometry result); + public DbGeometry AttrGeometryMultiLineString { get; set; } /// /// Required /// [Required] - public DbGeometry AttrGeometryMultiPoint - { - get - { - DbGeometry value = _attrGeometryMultiPoint; - GetAttrGeometryMultiPoint(ref value); - return (_attrGeometryMultiPoint = value); - } - set - { - DbGeometry oldValue = _attrGeometryMultiPoint; - SetAttrGeometryMultiPoint(oldValue, ref value); - if (oldValue != value) - { - _attrGeometryMultiPoint = value; - } - } - } - - /// - /// Backing field for AttrGeometryMultiPolygon - /// - protected DbGeometry _attrGeometryMultiPolygon; - /// - /// When provided in a partial class, allows value of AttrGeometryMultiPolygon to be changed before setting. - /// - partial void SetAttrGeometryMultiPolygon(DbGeometry oldValue, ref DbGeometry newValue); - /// - /// When provided in a partial class, allows value of AttrGeometryMultiPolygon to be changed before returning. - /// - partial void GetAttrGeometryMultiPolygon(ref DbGeometry result); + public DbGeometry AttrGeometryMultiPoint { get; set; } /// /// Required /// [Required] - public DbGeometry AttrGeometryMultiPolygon - { - get - { - DbGeometry value = _attrGeometryMultiPolygon; - GetAttrGeometryMultiPolygon(ref value); - return (_attrGeometryMultiPolygon = value); - } - set - { - DbGeometry oldValue = _attrGeometryMultiPolygon; - SetAttrGeometryMultiPolygon(oldValue, ref value); - if (oldValue != value) - { - _attrGeometryMultiPolygon = value; - } - } - } - - /// - /// Backing field for AttrGeometryPoint - /// - protected DbGeometry _attrGeometryPoint; - /// - /// When provided in a partial class, allows value of AttrGeometryPoint to be changed before setting. - /// - partial void SetAttrGeometryPoint(DbGeometry oldValue, ref DbGeometry newValue); - /// - /// When provided in a partial class, allows value of AttrGeometryPoint to be changed before returning. - /// - partial void GetAttrGeometryPoint(ref DbGeometry result); + public DbGeometry AttrGeometryMultiPolygon { get; set; } /// /// Required /// [Required] - public DbGeometry AttrGeometryPoint - { - get - { - DbGeometry value = _attrGeometryPoint; - GetAttrGeometryPoint(ref value); - return (_attrGeometryPoint = value); - } - set - { - DbGeometry oldValue = _attrGeometryPoint; - SetAttrGeometryPoint(oldValue, ref value); - if (oldValue != value) - { - _attrGeometryPoint = value; - } - } - } + public DbGeometry AttrGeometryPoint { get; set; } } } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/UChild.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/UChild.generated.cs index a98e0cce7..82b05bbcb 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/UChild.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/UChild.generated.cs @@ -58,7 +58,6 @@ public UChild(global::Testing.UParentRequired _uparentrequired1, global::Testing if (_uparentrequired2 == null) throw new ArgumentNullException(nameof(_uparentrequired2)); _uparentrequired2.UChildOptional = this; - Init(); } @@ -76,42 +75,12 @@ public static UChild Create(global::Testing.UParentRequired _uparentrequired1, g * Properties *************************************************************************/ - /// - /// Backing field for Id - /// - internal int _id; - /// - /// When provided in a partial class, allows value of Id to be changed before setting. - /// - partial void SetId(int oldValue, ref int newValue); - /// - /// When provided in a partial class, allows value of Id to be changed before returning. - /// - partial void GetId(ref int result); - /// /// Identity, Indexed, Required /// [Key] [Required] - public int Id - { - get - { - int value = _id; - GetId(ref value); - return (_id = value); - } - protected set - { - int oldValue = _id; - SetId(oldValue, ref value); - if (oldValue != value) - { - _id = value; - } - } - } + public int Id { get; set; } /************************************************************************* * Navigation properties diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/UParentCollection.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/UParentCollection.generated.cs index 57e7d17e8..f2909654e 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/UParentCollection.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/UParentCollection.generated.cs @@ -52,7 +52,6 @@ public UParentCollection(global::Testing.UChild uchildrequired) this.UChildRequired = uchildrequired; this.UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); - Init(); } @@ -69,108 +68,25 @@ public static UParentCollection Create(global::Testing.UChild uchildrequired) * Properties *************************************************************************/ - /// - /// Backing field for Id - /// - internal int _id; - /// - /// When provided in a partial class, allows value of Id to be changed before setting. - /// - partial void SetId(int oldValue, ref int newValue); - /// - /// When provided in a partial class, allows value of Id to be changed before returning. - /// - partial void GetId(ref int result); - /// /// Identity, Indexed, Required /// [Key] [Required] - public int Id - { - get - { - int value = _id; - GetId(ref value); - return (_id = value); - } - protected set - { - int oldValue = _id; - SetId(oldValue, ref value); - if (oldValue != value) - { - _id = value; - } - } - } + public int Id { get; set; } /************************************************************************* * Navigation properties *************************************************************************/ - protected global::Testing.UChild _uChildRequired; - partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); - partial void GetUChildRequired(ref global::Testing.UChild result); - /// /// Required /// - public virtual global::Testing.UChild UChildRequired - { - get - { - global::Testing.UChild value = _uChildRequired; - GetUChildRequired(ref value); - return (_uChildRequired = value); - } - set - { - global::Testing.UChild oldValue = _uChildRequired; - SetUChildRequired(oldValue, ref value); - if (oldValue != value) - { - _uChildRequired = value; - } - } - } + public virtual global::Testing.UChild UChildRequired { get; set; } - protected ICollection _uChildCollection; - public virtual ICollection UChildCollection - { - get - { - return _uChildCollection; - } - private set - { - _uChildCollection = value; - } - } - - protected global::Testing.UChild _uChildOptional; - partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); - partial void GetUChildOptional(ref global::Testing.UChild result); + public virtual ICollection UChildCollection { get; private set; } - public virtual global::Testing.UChild UChildOptional - { - get - { - global::Testing.UChild value = _uChildOptional; - GetUChildOptional(ref value); - return (_uChildOptional = value); - } - set - { - global::Testing.UChild oldValue = _uChildOptional; - SetUChildOptional(oldValue, ref value); - if (oldValue != value) - { - _uChildOptional = value; - } - } - } + public virtual global::Testing.UChild UChildOptional { get; set; } } } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/UParentOptional.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/UParentOptional.generated.cs index cdc50803b..467fa94de 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/UParentOptional.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/UParentOptional.generated.cs @@ -22,7 +22,8 @@ namespace Testing /// /// x /// - public partial class UParentOptional: global::Testing.HiddenEntity, INotifyPropertyChanged + [System.ComponentModel.Description("x")] + public partial class UParentOptional: global::Testing.HiddenEntity { partial void Init(); @@ -57,7 +58,6 @@ public UParentOptional(global::Testing.UChild uchildrequired) this.UChildRequired = uchildrequired; this.UChildCollection = new System.Collections.ObjectModel.ObservableCollection(); - Init(); } @@ -74,119 +74,31 @@ public static UParentOptional Create(global::Testing.UChild uchildrequired) * Properties *************************************************************************/ - /// - /// Backing field for PropertyInChild - /// - protected string _propertyInChild; - /// - /// When provided in a partial class, allows value of PropertyInChild to be changed before setting. - /// - partial void SetPropertyInChild(string oldValue, ref string newValue); - /// - /// When provided in a partial class, allows value of PropertyInChild to be changed before returning. - /// - partial void GetPropertyInChild(ref string result); - /// /// Default value = "hello" /// - public string PropertyInChild - { - get - { - string value = _propertyInChild; - GetPropertyInChild(ref value); - return (_propertyInChild = value); - } - set - { - string oldValue = _propertyInChild; - SetPropertyInChild(oldValue, ref value); - if (oldValue != value) - { - _propertyInChild = value; - } - } - } + public string PropertyInChild { get; set; } /************************************************************************* * Navigation properties *************************************************************************/ - protected global::Testing.UChild _uChildOptional; - partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); - partial void GetUChildOptional(ref global::Testing.UChild result); - /// /// x /// - public virtual global::Testing.UChild UChildOptional - { - get - { - global::Testing.UChild value = _uChildOptional; - GetUChildOptional(ref value); - return (_uChildOptional = value); - } - set - { - global::Testing.UChild oldValue = _uChildOptional; - SetUChildOptional(oldValue, ref value); - if (oldValue != value) - { - _uChildOptional = value; - } - } - } + [Description("x")] + public virtual global::Testing.UChild UChildOptional { get; set; } - protected ICollection _uChildCollection; /// /// h /// - public virtual ICollection UChildCollection - { - get - { - return _uChildCollection; - } - private set - { - _uChildCollection = value; - } - } - - protected global::Testing.UChild _uChildRequired; - partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); - partial void GetUChildRequired(ref global::Testing.UChild result); + [Description("h")] + public virtual ICollection UChildCollection { get; private set; } /// /// Required /// - public virtual global::Testing.UChild UChildRequired - { - get - { - global::Testing.UChild value = _uChildRequired; - GetUChildRequired(ref value); - return (_uChildRequired = value); - } - set - { - global::Testing.UChild oldValue = _uChildRequired; - SetUChildRequired(oldValue, ref value); - if (oldValue != value) - { - _uChildRequired = value; - } - } - } - - public virtual event PropertyChangedEventHandler PropertyChanged; - - protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } + public virtual global::Testing.UChild UChildRequired { get; set; } } } diff --git a/src/Testing/EF6/EF6NetStandard/Generated/Entities/UParentRequired.generated.cs b/src/Testing/EF6/EF6NetStandard/Generated/Entities/UParentRequired.generated.cs index 304681e19..77d69ed1c 100644 --- a/src/Testing/EF6/EF6NetStandard/Generated/Entities/UParentRequired.generated.cs +++ b/src/Testing/EF6/EF6NetStandard/Generated/Entities/UParentRequired.generated.cs @@ -38,108 +38,25 @@ public UParentRequired() * Properties *************************************************************************/ - /// - /// Backing field for Id - /// - internal int _id; - /// - /// When provided in a partial class, allows value of Id to be changed before setting. - /// - partial void SetId(int oldValue, ref int newValue); - /// - /// When provided in a partial class, allows value of Id to be changed before returning. - /// - partial void GetId(ref int result); - /// /// Identity, Indexed, Required /// [Key] [Required] - public int Id - { - get - { - int value = _id; - GetId(ref value); - return (_id = value); - } - protected set - { - int oldValue = _id; - SetId(oldValue, ref value); - if (oldValue != value) - { - _id = value; - } - } - } + public int Id { get; set; } /************************************************************************* * Navigation properties *************************************************************************/ - protected global::Testing.UChild _uChildRequired; - partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); - partial void GetUChildRequired(ref global::Testing.UChild result); - /// /// Required /// - public virtual global::Testing.UChild UChildRequired - { - get - { - global::Testing.UChild value = _uChildRequired; - GetUChildRequired(ref value); - return (_uChildRequired = value); - } - set - { - global::Testing.UChild oldValue = _uChildRequired; - SetUChildRequired(oldValue, ref value); - if (oldValue != value) - { - _uChildRequired = value; - } - } - } - - protected ICollection _uChildCollection; - public virtual ICollection UChildCollection - { - get - { - return _uChildCollection; - } - private set - { - _uChildCollection = value; - } - } + public virtual global::Testing.UChild UChildRequired { get; set; } - protected global::Testing.UChild _uChildOptional; - partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); - partial void GetUChildOptional(ref global::Testing.UChild result); + public virtual ICollection UChildCollection { get; private set; } - public virtual global::Testing.UChild UChildOptional - { - get - { - global::Testing.UChild value = _uChildOptional; - GetUChildOptional(ref value); - return (_uChildOptional = value); - } - set - { - global::Testing.UChild oldValue = _uChildOptional; - SetUChildOptional(oldValue, ref value); - if (oldValue != value) - { - _uChildOptional = value; - } - } - } + public virtual global::Testing.UChild UChildOptional { get; set; } } } diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/AllFeatureModel.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/AllFeatureModel.cs index 6153a7d78..47021ebc9 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/AllFeatureModel.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/AllFeatureModel.cs @@ -1 +1,1851 @@  +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class AllPropertyTypesRequired + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesRequired() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesRequired CreateAllPropertyTypesRequiredUnsafe() + { + return new AllPropertyTypesRequired(); + } + + /// + /// Public constructor with required data + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, string stringattr, TimeSpan timeattr) + { + this.BinaryAttr = binaryattr; + + this.BooleanAttr = booleanattr; + + this.ByteAttr = byteattr; + + this.DateTimeAttr = datetimeattr; + + this.DateTimeOffsetAttr = datetimeoffsetattr; + + this.DecimalAttr = decimalattr; + + this.DoubleAttr = doubleattr; + + this.GuidAttr = guidattr; + + this.Int16Attr = int16attr; + + this.Int32Attr = int32attr; + + this.Int64Attr = int64attr; + + this.SingleAttr = singleattr; + + if (string.IsNullOrEmpty(stringattr)) throw new ArgumentNullException(nameof(stringattr)); + this.StringAttr = stringattr; + + this.TimeAttr = timeattr; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static AllPropertyTypesRequired Create(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, string stringattr, TimeSpan timeattr) + { + return new AllPropertyTypesRequired(binaryattr, booleanattr, byteattr, datetimeattr, datetimeoffsetattr, decimalattr, doubleattr, guidattr, int16attr, int32attr, int64attr, singleattr, stringattr, timeattr); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + /// + /// Required + /// + [Required] + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool oldValue, ref bool newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool result); + + /// + /// Required + /// + [Required] + public bool BooleanAttr + { + get + { + bool value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte oldValue, ref byte newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte result); + + /// + /// Required + /// + [Required] + public byte ByteAttr + { + get + { + byte value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime oldValue, ref DateTime newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime result); + + /// + /// Required + /// + [Required] + public DateTime DateTimeAttr + { + get + { + DateTime value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset oldValue, ref DateTimeOffset newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset result); + + /// + /// Required + /// + [Required] + public DateTimeOffset DateTimeOffsetAttr + { + get + { + DateTimeOffset value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal oldValue, ref decimal newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal result); + + /// + /// Required + /// + [Required] + public decimal DecimalAttr + { + get + { + decimal value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double oldValue, ref double newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double result); + + /// + /// Required + /// + [Required] + public double DoubleAttr + { + get + { + double value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid oldValue, ref Guid newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid result); + + /// + /// Required + /// + [Required] + public Guid GuidAttr + { + get + { + Guid value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short oldValue, ref short newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short result); + + /// + /// Required + /// + [Required] + public short Int16Attr + { + get + { + short value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int result); + + /// + /// Required + /// + [Required] + public int Int32Attr + { + get + { + int value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long oldValue, ref long newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long result); + + /// + /// Required + /// + [Required] + public long Int64Attr + { + get + { + long value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single oldValue, ref Single newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single result); + + /// + /// Required + /// + [Required] + public Single SingleAttr + { + get + { + Single value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + /// + /// Required + /// + [Required] + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan oldValue, ref TimeSpan newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan result); + + /// + /// Required + /// + [Required] + public TimeSpan TimeAttr + { + get + { + TimeSpan value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class AllPropertyTypesOptional + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesOptional() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesOptional CreateAllPropertyTypesOptionalUnsafe() + { + return new AllPropertyTypesOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public AllPropertyTypesOptional(int id1) + { + this.Id1 = id1; + + this.OwnedType = new global::Testing.OwnedType(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static AllPropertyTypesOptional Create(int id1) + { + return new AllPropertyTypesOptional(id1); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool? _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool? oldValue, ref bool? newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool? result); + + public bool? BooleanAttr + { + get + { + bool? value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool? oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte? _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte? oldValue, ref byte? newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte? result); + + public byte? ByteAttr + { + get + { + byte? value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte? oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime? _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime? oldValue, ref DateTime? newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime? result); + + public DateTime? DateTimeAttr + { + get + { + DateTime? value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime? oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset? _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset? oldValue, ref DateTimeOffset? newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset? result); + + public DateTimeOffset? DateTimeOffsetAttr + { + get + { + DateTimeOffset? value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset? oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal? _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal? oldValue, ref decimal? newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal? result); + + public decimal? DecimalAttr + { + get + { + decimal? value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal? oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double? _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double? oldValue, ref double? newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double? result); + + public double? DoubleAttr + { + get + { + double? value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double? oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid? _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid? oldValue, ref Guid? newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid? result); + + public Guid? GuidAttr + { + get + { + Guid? value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid? oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short? _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short? oldValue, ref short? newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short? result); + + public short? Int16Attr + { + get + { + short? value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short? oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int? _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int? oldValue, ref int? newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int? result); + + public int? Int32Attr + { + get + { + int? value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int? oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long? _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long? oldValue, ref long? newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long? result); + + public long? Int64Attr + { + get + { + long? value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long? oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single? _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single? oldValue, ref Single? newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single? result); + + public Single? SingleAttr + { + get + { + Single? value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single? oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan? _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan? oldValue, ref TimeSpan? newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan? result); + + public TimeSpan? TimeAttr + { + get + { + TimeSpan? value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan? oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + /// + /// Backing field for Id1 + /// + internal int _id1; + /// + /// When provided in a partial class, allows value of Id1 to be changed before setting. + /// + partial void SetId1(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id1 to be changed before returning. + /// + partial void GetId1(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id1 + { + get + { + int value = _id1; + GetId1(ref value); + return (_id1 = value); + } + set + { + int oldValue = _id1; + SetId1(oldValue, ref value); + if (oldValue != value) + { + _id1 = value; + } + } + } + + /// + /// Concurrency token + /// + [Timestamp] + public Byte[] Timestamp { get; set; } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for OwnedType + /// + protected global::Testing.OwnedType _ownedType; + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before setting. + /// + partial void SetOwnedType(global::Testing.OwnedType oldValue, ref global::Testing.OwnedType newValue); + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before returning. + /// + partial void GetOwnedType(ref global::Testing.OwnedType result); + + public virtual global::Testing.OwnedType OwnedType + { + get + { + global::Testing.OwnedType value = _ownedType; + GetOwnedType(ref value); + return (_ownedType = value); + } + set + { + global::Testing.OwnedType oldValue = _ownedType; + SetOwnedType(oldValue, ref value); + if (oldValue != value) + { + _ownedType = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentRequired + { + partial void Init(); + + /// + /// Default constructor + /// + public UParentRequired() + { + UChildCollection = new System.Collections.Generic.HashSet(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentOptional: global::Testing.HiddenEntity + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentOptional(): base() + { + PropertyInChild = "hello"; + UChildCollection = new System.Collections.Generic.HashSet(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentOptional CreateUParentOptionalUnsafe() + { + return new UParentOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentOptional(global::Testing.UChild uchildrequired) + { + this.PropertyInChild = "hello"; + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + this.UChildCollection = new System.Collections.Generic.HashSet(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentOptional Create(global::Testing.UChild uchildrequired) + { + return new UParentOptional(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for PropertyInChild + /// + protected string _propertyInChild; + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before setting. + /// + partial void SetPropertyInChild(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before returning. + /// + partial void GetPropertyInChild(ref string result); + + /// + /// Default value = "hello" + /// + public string PropertyInChild + { + get + { + string value = _propertyInChild; + GetPropertyInChild(ref value); + return (_propertyInChild = value); + } + set + { + string oldValue = _propertyInChild; + SetPropertyInChild(oldValue, ref value); + if (oldValue != value) + { + _propertyInChild = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentCollection + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentCollection() + { + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentCollection CreateUParentCollectionUnsafe() + { + return new UParentCollection(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentCollection(global::Testing.UChild uchildrequired) + { + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentCollection Create(global::Testing.UChild uchildrequired) + { + return new UParentCollection(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UChild + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UChild() + { + // NOTE: This class has one-to-one associations with UChild. + // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other. + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UChild CreateUChildUnsafe() + { + return new UChild(); + } + + /// + /// Public constructor with required data + /// diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Context/AllFeatureModel.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Context/AllFeatureModel.generated.cs index 8b4ef3701..b58a5a1b4 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Context/AllFeatureModel.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Context/AllFeatureModel.generated.cs @@ -76,7 +76,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().ToTable("AllPropertyTypesOptionals").HasKey(t => new { t.Id, t.Id1 }); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.BinaryAttr).HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.BooleanAttr).HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.ByteAttr).HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); @@ -91,76 +91,76 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.SingleAttr).HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.StringAttr).HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.TimeAttr).HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Id1).IsRequired().HasField("_id1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever(); + modelBuilder.Entity().Property(t => t.Id1).HasField("_id1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever().IsRequired(); modelBuilder.Entity().Property("Timestamp").IsConcurrencyToken(); modelBuilder.Entity().OwnsOne(p => p.OwnedType).Property(p => p.SingleAttr); modelBuilder.Entity().ToTable("AllPropertyTypesRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().Property(t => t.BinaryAttr).IsRequired().HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.BooleanAttr).IsRequired().HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.ByteAttr).IsRequired().HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DateTimeAttr).IsRequired().HasField("_dateTimeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DateTimeOffsetAttr).IsRequired().HasField("_dateTimeOffsetAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DecimalAttr).IsRequired().HasField("_decimalAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DoubleAttr).IsRequired().HasField("_doubleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.GuidAttr).IsRequired().HasField("_guidAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int16Attr).IsRequired().HasField("_int16Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int32Attr).IsRequired().HasField("_int32Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int64Attr).IsRequired().HasField("_int64Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.SingleAttr).IsRequired().HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.StringAttr).IsRequired().HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.TimeAttr).IsRequired().HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().Property(t => t.BinaryAttr).HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.BooleanAttr).HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.ByteAttr).HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DateTimeAttr).HasField("_dateTimeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DateTimeOffsetAttr).HasField("_dateTimeOffsetAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DecimalAttr).HasField("_decimalAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DoubleAttr).HasField("_doubleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.GuidAttr).HasField("_guidAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int16Attr).HasField("_int16Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int32Attr).HasField("_int32Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int64Attr).HasField("_int64Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.SingleAttr).HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.StringAttr).HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.TimeAttr).HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().ToTable("BaseClassWithRequiredProperties").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().Property(t => t.Property0).IsRequired().HasField("_property0").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().Property(t => t.Property0).HasField("_property0").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().ToTable("BChilds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("BParentCollections").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithMany(p => p.BParentCollection).HasForeignKey("BChildRequiredId"); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithMany(p => p.BParentCollection_2).HasForeignKey("BChildOptionalId"); modelBuilder.Entity().ToTable("BParentOptionals").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentOptional).HasForeignKey("BParentOptional", "BChildRequiredId"); modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentOptional_1).HasForeignKey("BParentOptional_1Id"); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentOptional_2).HasForeignKey("BChild", "BParentOptional_2Id"); modelBuilder.Entity().ToTable("BParentRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentRequired).HasForeignKey("BChild", "BParentRequiredId").IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentRequired_1).HasForeignKey("BChild", "BParentRequired_1Id"); modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentRequired_2).HasForeignKey("BParentRequired_2Id").IsRequired(); modelBuilder.Entity().ToTable("Children").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasMany(p => p.Children).WithOne(p => p.Parent).HasForeignKey("ParentId").IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Property1).IsRequired().HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("HiddenEntities").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("Masters").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasMany(p => p.Children).WithOne().HasForeignKey("Master_Children_Id").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasMany(p => p.Children).WithOne().HasForeignKey("MasterChildrenId").IsRequired(); modelBuilder.Owned(); modelBuilder.Entity().ToTable("ParserTests").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.name1).HasField("_name1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.name2).HasField("_name2").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.name3).HasField("_name3").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); @@ -181,26 +181,26 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.name18).HasField("_name18").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("RenamedColumns").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasColumnName("Foo").HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasColumnName("Foo").HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("UChilds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("UParentCollections").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.UChildRequired).WithMany().HasForeignKey("UChildRequiredId"); modelBuilder.Entity().HasOne(p => p.UChildOptional).WithMany().HasForeignKey("UChildOptionalId"); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentOptional_UChildOptional_Id"); - modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentOptional_UChildCollection_Id"); + modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentOptionalUChildOptionalId"); + modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentOptionalUChildCollectionId"); modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UParentOptional", "UChildRequiredId"); modelBuilder.Entity().ToTable("UParentRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UChild", "UParentRequired_UChildRequired_Id"); - modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentRequired_UChildCollection_Id").IsRequired(); - modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentRequired_UChildOptional_Id").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UChild", "UParentRequiredUChildRequiredId"); + modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentRequiredUChildCollectionId").IsRequired(); + modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentRequiredUChildOptionalId").IsRequired(); OnModelCreatedImpl(modelBuilder); } diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/AbstractBaseClass.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/AbstractBaseClass.generated.cs index f506f1cf1..8118b33b2 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/AbstractBaseClass.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/AbstractBaseClass.generated.cs @@ -39,7 +39,6 @@ protected AbstractBaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/AllPropertyTypesOptional.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/AllPropertyTypesOptional.generated.cs index a31e28272..4ed270044 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/AllPropertyTypesOptional.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/AllPropertyTypesOptional.generated.cs @@ -47,7 +47,6 @@ public AllPropertyTypesOptional(int id1) this.Id1 = id1; this.OwnedType = new global::Testing.OwnedType(); - Init(); } @@ -90,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -596,8 +595,19 @@ public int Id1 * Navigation properties *************************************************************************/ + /// + /// Backing field for OwnedType + /// protected global::Testing.OwnedType _ownedType; + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before setting. + /// partial void SetOwnedType(global::Testing.OwnedType oldValue, ref global::Testing.OwnedType newValue); + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before returning. + /// partial void GetOwnedType(ref global::Testing.OwnedType result); public virtual global::Testing.OwnedType OwnedType diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/AllPropertyTypesRequired.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/AllPropertyTypesRequired.generated.cs index 965a5474b..bf799d306 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/AllPropertyTypesRequired.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/AllPropertyTypesRequired.generated.cs @@ -86,7 +86,6 @@ public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteat this.TimeAttr = timeattr; - Init(); } @@ -142,7 +141,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BChild.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BChild.generated.cs index 802976967..7c03d3986 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BChild.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BChild.generated.cs @@ -59,13 +59,14 @@ public BChild(global::Testing.BParentRequired bparentrequired, global::Testing.B if (bparentrequired == null) throw new ArgumentNullException(nameof(bparentrequired)); this.BParentRequired = bparentrequired; + bparentrequired.BChildOptional = this; if (bparentrequired_2 == null) throw new ArgumentNullException(nameof(bparentrequired_2)); this.BParentRequired_2 = bparentrequired_2; + bparentrequired_2.BChildCollection.Add(this); this.BParentCollection = new System.Collections.Generic.HashSet(); this.BParentCollection_2 = new System.Collections.Generic.HashSet(); - Init(); } @@ -109,7 +110,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BParentCollection.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BParentCollection.generated.cs index af5faf66c..720d8ff41 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BParentCollection.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BParentCollection.generated.cs @@ -48,7 +48,7 @@ public BParentCollection(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; - + bchildrequired.BParentCollection.Add(this); Init(); } @@ -92,7 +92,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -107,8 +107,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -133,8 +144,19 @@ protected set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BParentOptional.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BParentOptional.generated.cs index 8c4093fa7..a3847a676 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BParentOptional.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BParentOptional.generated.cs @@ -49,9 +49,9 @@ public BParentOptional(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; + bchildrequired.BParentOptional = this; this.BChildCollection = new System.Collections.Generic.HashSet(); - Init(); } @@ -94,7 +94,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -109,8 +109,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -135,7 +146,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get @@ -148,8 +163,19 @@ private set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BParentRequired.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BParentRequired.generated.cs index e9d71bdd2..fab838807 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BParentRequired.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BParentRequired.generated.cs @@ -63,7 +63,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -78,8 +78,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional @@ -101,8 +112,19 @@ protected set } } + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -127,7 +149,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BaseClass.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BaseClass.generated.cs index 1e11e199e..ab595e96c 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BaseClass.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BaseClass.generated.cs @@ -47,7 +47,6 @@ public BaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BaseClassWithRequiredProperties.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BaseClassWithRequiredProperties.generated.cs index bb337a79e..557698cc4 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BaseClassWithRequiredProperties.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/BaseClassWithRequiredProperties.generated.cs @@ -47,7 +47,6 @@ public BaseClassWithRequiredProperties(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } @@ -90,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/Child.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/Child.generated.cs index 355e18745..de2ef22b8 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/Child.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/Child.generated.cs @@ -50,12 +50,12 @@ public Child(global::Testing.Child parent, global::Testing.Master _master0) { if (parent == null) throw new ArgumentNullException(nameof(parent)); this.Parent = parent; + parent.Children.Add(this); if (_master0 == null) throw new ArgumentNullException(nameof(_master0)); _master0.Children.Add(this); this.Children = new System.Collections.Generic.HashSet(); - Init(); } @@ -99,7 +99,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -114,7 +114,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/ConcreteDerivedClass.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/ConcreteDerivedClass.generated.cs index cee4e6783..b05619dd1 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/ConcreteDerivedClass.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/ConcreteDerivedClass.generated.cs @@ -47,7 +47,6 @@ public ConcreteDerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs index b3fa04fdb..84cd0bc5c 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs @@ -51,7 +51,6 @@ public ConcreteDerivedClassWithRequiredProperties(string property1, string prope if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/DerivedClass.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/DerivedClass.generated.cs index 33e54b6e6..59dd6f39f 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/DerivedClass.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/DerivedClass.generated.cs @@ -47,7 +47,6 @@ public DerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/HiddenEntity.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/HiddenEntity.generated.cs index caa5dcc02..3ae611794 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/HiddenEntity.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/HiddenEntity.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/Master.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/Master.generated.cs index fd5ed86b8..61807d30b 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/Master.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/Master.generated.cs @@ -62,7 +62,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -77,7 +77,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/OwnedType.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/OwnedType.generated.cs index 356934d5a..66af3d729 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/OwnedType.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/OwnedType.generated.cs @@ -39,7 +39,6 @@ public OwnedType(global::Testing.AllPropertyTypesOptional _allpropertytypesoptio if (_allpropertytypesoptional0 == null) throw new ArgumentNullException(nameof(_allpropertytypesoptional0)); _allpropertytypesoptional0.OwnedType = this; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/ParserTest.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/ParserTest.generated.cs index 261469691..aa8ab86c0 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/ParserTest.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/ParserTest.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/RenamedColumn.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/RenamedColumn.generated.cs index e12f1a4c5..97af66423 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/RenamedColumn.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/RenamedColumn.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/UChild.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/UChild.generated.cs index bc67ba3d7..9b1d7572d 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/UChild.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/UChild.generated.cs @@ -57,7 +57,6 @@ public UChild(global::Testing.UParentRequired _uparentrequired1, global::Testing if (_uparentrequired2 == null) throw new ArgumentNullException(nameof(_uparentrequired2)); _uparentrequired2.UChildOptional = this; - Init(); } @@ -101,7 +100,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/UParentCollection.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/UParentCollection.generated.cs index b2fe3516b..2c7cd4500 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/UParentCollection.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/UParentCollection.generated.cs @@ -49,7 +49,6 @@ public UParentCollection(global::Testing.UChild uchildrequired) if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); this.UChildRequired = uchildrequired; - Init(); } @@ -92,7 +91,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -107,8 +106,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -133,8 +143,19 @@ protected set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/UParentOptional.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/UParentOptional.generated.cs index e27bf7bb8..f76725ae6 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/UParentOptional.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/UParentOptional.generated.cs @@ -53,7 +53,6 @@ public UParentOptional(global::Testing.UChild uchildrequired) this.UChildRequired = uchildrequired; this.UChildCollection = new System.Collections.Generic.HashSet(); - Init(); } @@ -109,8 +108,19 @@ public string PropertyInChild * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional @@ -132,7 +142,11 @@ public string PropertyInChild } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -145,8 +159,19 @@ private set } } + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// diff --git a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/UParentRequired.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/UParentRequired.generated.cs index be5063e5f..39ebd0f6a 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/UParentRequired.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore2/Generated/Entities/UParentRequired.generated.cs @@ -63,7 +63,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -78,8 +78,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -104,7 +115,11 @@ protected set } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -117,8 +132,19 @@ private set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/AllFeatureModel.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/AllFeatureModel.cs index 6153a7d78..47021ebc9 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/AllFeatureModel.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/AllFeatureModel.cs @@ -1 +1,1851 @@  +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class AllPropertyTypesRequired + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesRequired() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesRequired CreateAllPropertyTypesRequiredUnsafe() + { + return new AllPropertyTypesRequired(); + } + + /// + /// Public constructor with required data + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, string stringattr, TimeSpan timeattr) + { + this.BinaryAttr = binaryattr; + + this.BooleanAttr = booleanattr; + + this.ByteAttr = byteattr; + + this.DateTimeAttr = datetimeattr; + + this.DateTimeOffsetAttr = datetimeoffsetattr; + + this.DecimalAttr = decimalattr; + + this.DoubleAttr = doubleattr; + + this.GuidAttr = guidattr; + + this.Int16Attr = int16attr; + + this.Int32Attr = int32attr; + + this.Int64Attr = int64attr; + + this.SingleAttr = singleattr; + + if (string.IsNullOrEmpty(stringattr)) throw new ArgumentNullException(nameof(stringattr)); + this.StringAttr = stringattr; + + this.TimeAttr = timeattr; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static AllPropertyTypesRequired Create(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, string stringattr, TimeSpan timeattr) + { + return new AllPropertyTypesRequired(binaryattr, booleanattr, byteattr, datetimeattr, datetimeoffsetattr, decimalattr, doubleattr, guidattr, int16attr, int32attr, int64attr, singleattr, stringattr, timeattr); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + /// + /// Required + /// + [Required] + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool oldValue, ref bool newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool result); + + /// + /// Required + /// + [Required] + public bool BooleanAttr + { + get + { + bool value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte oldValue, ref byte newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte result); + + /// + /// Required + /// + [Required] + public byte ByteAttr + { + get + { + byte value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime oldValue, ref DateTime newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime result); + + /// + /// Required + /// + [Required] + public DateTime DateTimeAttr + { + get + { + DateTime value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset oldValue, ref DateTimeOffset newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset result); + + /// + /// Required + /// + [Required] + public DateTimeOffset DateTimeOffsetAttr + { + get + { + DateTimeOffset value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal oldValue, ref decimal newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal result); + + /// + /// Required + /// + [Required] + public decimal DecimalAttr + { + get + { + decimal value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double oldValue, ref double newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double result); + + /// + /// Required + /// + [Required] + public double DoubleAttr + { + get + { + double value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid oldValue, ref Guid newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid result); + + /// + /// Required + /// + [Required] + public Guid GuidAttr + { + get + { + Guid value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short oldValue, ref short newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short result); + + /// + /// Required + /// + [Required] + public short Int16Attr + { + get + { + short value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int result); + + /// + /// Required + /// + [Required] + public int Int32Attr + { + get + { + int value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long oldValue, ref long newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long result); + + /// + /// Required + /// + [Required] + public long Int64Attr + { + get + { + long value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single oldValue, ref Single newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single result); + + /// + /// Required + /// + [Required] + public Single SingleAttr + { + get + { + Single value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + /// + /// Required + /// + [Required] + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan oldValue, ref TimeSpan newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan result); + + /// + /// Required + /// + [Required] + public TimeSpan TimeAttr + { + get + { + TimeSpan value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class AllPropertyTypesOptional + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesOptional() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesOptional CreateAllPropertyTypesOptionalUnsafe() + { + return new AllPropertyTypesOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public AllPropertyTypesOptional(int id1) + { + this.Id1 = id1; + + this.OwnedType = new global::Testing.OwnedType(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static AllPropertyTypesOptional Create(int id1) + { + return new AllPropertyTypesOptional(id1); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool? _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool? oldValue, ref bool? newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool? result); + + public bool? BooleanAttr + { + get + { + bool? value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool? oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte? _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte? oldValue, ref byte? newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte? result); + + public byte? ByteAttr + { + get + { + byte? value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte? oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime? _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime? oldValue, ref DateTime? newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime? result); + + public DateTime? DateTimeAttr + { + get + { + DateTime? value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime? oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset? _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset? oldValue, ref DateTimeOffset? newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset? result); + + public DateTimeOffset? DateTimeOffsetAttr + { + get + { + DateTimeOffset? value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset? oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal? _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal? oldValue, ref decimal? newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal? result); + + public decimal? DecimalAttr + { + get + { + decimal? value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal? oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double? _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double? oldValue, ref double? newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double? result); + + public double? DoubleAttr + { + get + { + double? value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double? oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid? _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid? oldValue, ref Guid? newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid? result); + + public Guid? GuidAttr + { + get + { + Guid? value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid? oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short? _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short? oldValue, ref short? newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short? result); + + public short? Int16Attr + { + get + { + short? value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short? oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int? _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int? oldValue, ref int? newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int? result); + + public int? Int32Attr + { + get + { + int? value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int? oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long? _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long? oldValue, ref long? newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long? result); + + public long? Int64Attr + { + get + { + long? value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long? oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single? _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single? oldValue, ref Single? newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single? result); + + public Single? SingleAttr + { + get + { + Single? value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single? oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan? _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan? oldValue, ref TimeSpan? newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan? result); + + public TimeSpan? TimeAttr + { + get + { + TimeSpan? value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan? oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + /// + /// Backing field for Id1 + /// + internal int _id1; + /// + /// When provided in a partial class, allows value of Id1 to be changed before setting. + /// + partial void SetId1(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id1 to be changed before returning. + /// + partial void GetId1(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id1 + { + get + { + int value = _id1; + GetId1(ref value); + return (_id1 = value); + } + set + { + int oldValue = _id1; + SetId1(oldValue, ref value); + if (oldValue != value) + { + _id1 = value; + } + } + } + + /// + /// Concurrency token + /// + [Timestamp] + public Byte[] Timestamp { get; set; } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for OwnedType + /// + protected global::Testing.OwnedType _ownedType; + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before setting. + /// + partial void SetOwnedType(global::Testing.OwnedType oldValue, ref global::Testing.OwnedType newValue); + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before returning. + /// + partial void GetOwnedType(ref global::Testing.OwnedType result); + + public virtual global::Testing.OwnedType OwnedType + { + get + { + global::Testing.OwnedType value = _ownedType; + GetOwnedType(ref value); + return (_ownedType = value); + } + set + { + global::Testing.OwnedType oldValue = _ownedType; + SetOwnedType(oldValue, ref value); + if (oldValue != value) + { + _ownedType = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentRequired + { + partial void Init(); + + /// + /// Default constructor + /// + public UParentRequired() + { + UChildCollection = new System.Collections.Generic.HashSet(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentOptional: global::Testing.HiddenEntity + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentOptional(): base() + { + PropertyInChild = "hello"; + UChildCollection = new System.Collections.Generic.HashSet(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentOptional CreateUParentOptionalUnsafe() + { + return new UParentOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentOptional(global::Testing.UChild uchildrequired) + { + this.PropertyInChild = "hello"; + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + this.UChildCollection = new System.Collections.Generic.HashSet(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentOptional Create(global::Testing.UChild uchildrequired) + { + return new UParentOptional(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for PropertyInChild + /// + protected string _propertyInChild; + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before setting. + /// + partial void SetPropertyInChild(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before returning. + /// + partial void GetPropertyInChild(ref string result); + + /// + /// Default value = "hello" + /// + public string PropertyInChild + { + get + { + string value = _propertyInChild; + GetPropertyInChild(ref value); + return (_propertyInChild = value); + } + set + { + string oldValue = _propertyInChild; + SetPropertyInChild(oldValue, ref value); + if (oldValue != value) + { + _propertyInChild = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentCollection + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentCollection() + { + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentCollection CreateUParentCollectionUnsafe() + { + return new UParentCollection(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentCollection(global::Testing.UChild uchildrequired) + { + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentCollection Create(global::Testing.UChild uchildrequired) + { + return new UParentCollection(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UChild + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UChild() + { + // NOTE: This class has one-to-one associations with UChild. + // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other. + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UChild CreateUChildUnsafe() + { + return new UChild(); + } + + /// + /// Public constructor with required data + /// diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Context/AllFeatureModel.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Context/AllFeatureModel.generated.cs index 8b4ef3701..b58a5a1b4 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Context/AllFeatureModel.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Context/AllFeatureModel.generated.cs @@ -76,7 +76,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().ToTable("AllPropertyTypesOptionals").HasKey(t => new { t.Id, t.Id1 }); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.BinaryAttr).HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.BooleanAttr).HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.ByteAttr).HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); @@ -91,76 +91,76 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.SingleAttr).HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.StringAttr).HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.TimeAttr).HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Id1).IsRequired().HasField("_id1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever(); + modelBuilder.Entity().Property(t => t.Id1).HasField("_id1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever().IsRequired(); modelBuilder.Entity().Property("Timestamp").IsConcurrencyToken(); modelBuilder.Entity().OwnsOne(p => p.OwnedType).Property(p => p.SingleAttr); modelBuilder.Entity().ToTable("AllPropertyTypesRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().Property(t => t.BinaryAttr).IsRequired().HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.BooleanAttr).IsRequired().HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.ByteAttr).IsRequired().HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DateTimeAttr).IsRequired().HasField("_dateTimeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DateTimeOffsetAttr).IsRequired().HasField("_dateTimeOffsetAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DecimalAttr).IsRequired().HasField("_decimalAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DoubleAttr).IsRequired().HasField("_doubleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.GuidAttr).IsRequired().HasField("_guidAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int16Attr).IsRequired().HasField("_int16Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int32Attr).IsRequired().HasField("_int32Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int64Attr).IsRequired().HasField("_int64Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.SingleAttr).IsRequired().HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.StringAttr).IsRequired().HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.TimeAttr).IsRequired().HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().Property(t => t.BinaryAttr).HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.BooleanAttr).HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.ByteAttr).HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DateTimeAttr).HasField("_dateTimeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DateTimeOffsetAttr).HasField("_dateTimeOffsetAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DecimalAttr).HasField("_decimalAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DoubleAttr).HasField("_doubleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.GuidAttr).HasField("_guidAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int16Attr).HasField("_int16Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int32Attr).HasField("_int32Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int64Attr).HasField("_int64Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.SingleAttr).HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.StringAttr).HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.TimeAttr).HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().ToTable("BaseClassWithRequiredProperties").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().Property(t => t.Property0).IsRequired().HasField("_property0").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().Property(t => t.Property0).HasField("_property0").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().ToTable("BChilds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("BParentCollections").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithMany(p => p.BParentCollection).HasForeignKey("BChildRequiredId"); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithMany(p => p.BParentCollection_2).HasForeignKey("BChildOptionalId"); modelBuilder.Entity().ToTable("BParentOptionals").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentOptional).HasForeignKey("BParentOptional", "BChildRequiredId"); modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentOptional_1).HasForeignKey("BParentOptional_1Id"); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentOptional_2).HasForeignKey("BChild", "BParentOptional_2Id"); modelBuilder.Entity().ToTable("BParentRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentRequired).HasForeignKey("BChild", "BParentRequiredId").IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentRequired_1).HasForeignKey("BChild", "BParentRequired_1Id"); modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentRequired_2).HasForeignKey("BParentRequired_2Id").IsRequired(); modelBuilder.Entity().ToTable("Children").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasMany(p => p.Children).WithOne(p => p.Parent).HasForeignKey("ParentId").IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Property1).IsRequired().HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("HiddenEntities").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("Masters").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasMany(p => p.Children).WithOne().HasForeignKey("Master_Children_Id").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasMany(p => p.Children).WithOne().HasForeignKey("MasterChildrenId").IsRequired(); modelBuilder.Owned(); modelBuilder.Entity().ToTable("ParserTests").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.name1).HasField("_name1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.name2).HasField("_name2").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.name3).HasField("_name3").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); @@ -181,26 +181,26 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.name18).HasField("_name18").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("RenamedColumns").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasColumnName("Foo").HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasColumnName("Foo").HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("UChilds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("UParentCollections").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.UChildRequired).WithMany().HasForeignKey("UChildRequiredId"); modelBuilder.Entity().HasOne(p => p.UChildOptional).WithMany().HasForeignKey("UChildOptionalId"); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentOptional_UChildOptional_Id"); - modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentOptional_UChildCollection_Id"); + modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentOptionalUChildOptionalId"); + modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentOptionalUChildCollectionId"); modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UParentOptional", "UChildRequiredId"); modelBuilder.Entity().ToTable("UParentRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UChild", "UParentRequired_UChildRequired_Id"); - modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentRequired_UChildCollection_Id").IsRequired(); - modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentRequired_UChildOptional_Id").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UChild", "UParentRequiredUChildRequiredId"); + modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentRequiredUChildCollectionId").IsRequired(); + modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentRequiredUChildOptionalId").IsRequired(); OnModelCreatedImpl(modelBuilder); } diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/AbstractBaseClass.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/AbstractBaseClass.generated.cs index f506f1cf1..8118b33b2 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/AbstractBaseClass.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/AbstractBaseClass.generated.cs @@ -39,7 +39,6 @@ protected AbstractBaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/AllPropertyTypesOptional.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/AllPropertyTypesOptional.generated.cs index a31e28272..4ed270044 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/AllPropertyTypesOptional.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/AllPropertyTypesOptional.generated.cs @@ -47,7 +47,6 @@ public AllPropertyTypesOptional(int id1) this.Id1 = id1; this.OwnedType = new global::Testing.OwnedType(); - Init(); } @@ -90,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -596,8 +595,19 @@ public int Id1 * Navigation properties *************************************************************************/ + /// + /// Backing field for OwnedType + /// protected global::Testing.OwnedType _ownedType; + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before setting. + /// partial void SetOwnedType(global::Testing.OwnedType oldValue, ref global::Testing.OwnedType newValue); + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before returning. + /// partial void GetOwnedType(ref global::Testing.OwnedType result); public virtual global::Testing.OwnedType OwnedType diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/AllPropertyTypesRequired.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/AllPropertyTypesRequired.generated.cs index 965a5474b..bf799d306 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/AllPropertyTypesRequired.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/AllPropertyTypesRequired.generated.cs @@ -86,7 +86,6 @@ public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteat this.TimeAttr = timeattr; - Init(); } @@ -142,7 +141,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BChild.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BChild.generated.cs index 802976967..7c03d3986 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BChild.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BChild.generated.cs @@ -59,13 +59,14 @@ public BChild(global::Testing.BParentRequired bparentrequired, global::Testing.B if (bparentrequired == null) throw new ArgumentNullException(nameof(bparentrequired)); this.BParentRequired = bparentrequired; + bparentrequired.BChildOptional = this; if (bparentrequired_2 == null) throw new ArgumentNullException(nameof(bparentrequired_2)); this.BParentRequired_2 = bparentrequired_2; + bparentrequired_2.BChildCollection.Add(this); this.BParentCollection = new System.Collections.Generic.HashSet(); this.BParentCollection_2 = new System.Collections.Generic.HashSet(); - Init(); } @@ -109,7 +110,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BParentCollection.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BParentCollection.generated.cs index af5faf66c..720d8ff41 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BParentCollection.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BParentCollection.generated.cs @@ -48,7 +48,7 @@ public BParentCollection(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; - + bchildrequired.BParentCollection.Add(this); Init(); } @@ -92,7 +92,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -107,8 +107,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -133,8 +144,19 @@ protected set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BParentOptional.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BParentOptional.generated.cs index 8c4093fa7..a3847a676 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BParentOptional.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BParentOptional.generated.cs @@ -49,9 +49,9 @@ public BParentOptional(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; + bchildrequired.BParentOptional = this; this.BChildCollection = new System.Collections.Generic.HashSet(); - Init(); } @@ -94,7 +94,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -109,8 +109,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -135,7 +146,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get @@ -148,8 +163,19 @@ private set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BParentRequired.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BParentRequired.generated.cs index e9d71bdd2..fab838807 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BParentRequired.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BParentRequired.generated.cs @@ -63,7 +63,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -78,8 +78,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional @@ -101,8 +112,19 @@ protected set } } + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -127,7 +149,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BaseClass.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BaseClass.generated.cs index 1e11e199e..ab595e96c 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BaseClass.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BaseClass.generated.cs @@ -47,7 +47,6 @@ public BaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BaseClassWithRequiredProperties.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BaseClassWithRequiredProperties.generated.cs index bb337a79e..557698cc4 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BaseClassWithRequiredProperties.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/BaseClassWithRequiredProperties.generated.cs @@ -47,7 +47,6 @@ public BaseClassWithRequiredProperties(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } @@ -90,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/Child.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/Child.generated.cs index 355e18745..de2ef22b8 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/Child.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/Child.generated.cs @@ -50,12 +50,12 @@ public Child(global::Testing.Child parent, global::Testing.Master _master0) { if (parent == null) throw new ArgumentNullException(nameof(parent)); this.Parent = parent; + parent.Children.Add(this); if (_master0 == null) throw new ArgumentNullException(nameof(_master0)); _master0.Children.Add(this); this.Children = new System.Collections.Generic.HashSet(); - Init(); } @@ -99,7 +99,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -114,7 +114,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/ConcreteDerivedClass.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/ConcreteDerivedClass.generated.cs index cee4e6783..b05619dd1 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/ConcreteDerivedClass.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/ConcreteDerivedClass.generated.cs @@ -47,7 +47,6 @@ public ConcreteDerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs index b3fa04fdb..84cd0bc5c 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs @@ -51,7 +51,6 @@ public ConcreteDerivedClassWithRequiredProperties(string property1, string prope if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/DerivedClass.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/DerivedClass.generated.cs index 33e54b6e6..59dd6f39f 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/DerivedClass.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/DerivedClass.generated.cs @@ -47,7 +47,6 @@ public DerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/HiddenEntity.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/HiddenEntity.generated.cs index caa5dcc02..3ae611794 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/HiddenEntity.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/HiddenEntity.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/Master.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/Master.generated.cs index fd5ed86b8..61807d30b 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/Master.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/Master.generated.cs @@ -62,7 +62,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -77,7 +77,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/OwnedType.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/OwnedType.generated.cs index 356934d5a..66af3d729 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/OwnedType.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/OwnedType.generated.cs @@ -39,7 +39,6 @@ public OwnedType(global::Testing.AllPropertyTypesOptional _allpropertytypesoptio if (_allpropertytypesoptional0 == null) throw new ArgumentNullException(nameof(_allpropertytypesoptional0)); _allpropertytypesoptional0.OwnedType = this; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/ParserTest.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/ParserTest.generated.cs index 261469691..aa8ab86c0 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/ParserTest.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/ParserTest.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/RenamedColumn.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/RenamedColumn.generated.cs index e12f1a4c5..97af66423 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/RenamedColumn.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/RenamedColumn.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/UChild.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/UChild.generated.cs index bc67ba3d7..9b1d7572d 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/UChild.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/UChild.generated.cs @@ -57,7 +57,6 @@ public UChild(global::Testing.UParentRequired _uparentrequired1, global::Testing if (_uparentrequired2 == null) throw new ArgumentNullException(nameof(_uparentrequired2)); _uparentrequired2.UChildOptional = this; - Init(); } @@ -101,7 +100,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/UParentCollection.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/UParentCollection.generated.cs index b2fe3516b..2c7cd4500 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/UParentCollection.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/UParentCollection.generated.cs @@ -49,7 +49,6 @@ public UParentCollection(global::Testing.UChild uchildrequired) if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); this.UChildRequired = uchildrequired; - Init(); } @@ -92,7 +91,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -107,8 +106,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -133,8 +143,19 @@ protected set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/UParentOptional.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/UParentOptional.generated.cs index e27bf7bb8..f76725ae6 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/UParentOptional.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/UParentOptional.generated.cs @@ -53,7 +53,6 @@ public UParentOptional(global::Testing.UChild uchildrequired) this.UChildRequired = uchildrequired; this.UChildCollection = new System.Collections.Generic.HashSet(); - Init(); } @@ -109,8 +108,19 @@ public string PropertyInChild * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional @@ -132,7 +142,11 @@ public string PropertyInChild } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -145,8 +159,19 @@ private set } } + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// diff --git a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/UParentRequired.generated.cs b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/UParentRequired.generated.cs index be5063e5f..39ebd0f6a 100644 --- a/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/UParentRequired.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetCore3/Generated/Entities/UParentRequired.generated.cs @@ -63,7 +63,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -78,8 +78,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -104,7 +115,11 @@ protected set } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -117,8 +132,19 @@ private set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/AllFeatureModel.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/AllFeatureModel.cs index 6153a7d78..8397ec2cd 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/AllFeatureModel.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/AllFeatureModel.cs @@ -1 +1,1597 @@  +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class AllPropertyTypesRequired + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesRequired() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesRequired CreateAllPropertyTypesRequiredUnsafe() + { + return new AllPropertyTypesRequired(); + } + + /// + /// Public constructor with required data + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, string stringattr, TimeSpan timeattr) + { + this.BinaryAttr = binaryattr; + + this.BooleanAttr = booleanattr; + + this.ByteAttr = byteattr; + + this.DateTimeAttr = datetimeattr; + + this.DateTimeOffsetAttr = datetimeoffsetattr; + + this.DecimalAttr = decimalattr; + + this.DoubleAttr = doubleattr; + + this.GuidAttr = guidattr; + + this.Int16Attr = int16attr; + + this.Int32Attr = int32attr; + + this.Int64Attr = int64attr; + + this.SingleAttr = singleattr; + + if (string.IsNullOrEmpty(stringattr)) throw new ArgumentNullException(nameof(stringattr)); + this.StringAttr = stringattr; + + this.TimeAttr = timeattr; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static AllPropertyTypesRequired Create(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, string stringattr, TimeSpan timeattr) + { + return new AllPropertyTypesRequired(binaryattr, booleanattr, byteattr, datetimeattr, datetimeoffsetattr, decimalattr, doubleattr, guidattr, int16attr, int32attr, int64attr, singleattr, stringattr, timeattr); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + /// + /// Required + /// + [Required] + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool oldValue, ref bool newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool result); + + /// + /// Required + /// + [Required] + public bool BooleanAttr + { + get + { + bool value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte oldValue, ref byte newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte result); + + /// + /// Required + /// + [Required] + public byte ByteAttr + { + get + { + byte value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime oldValue, ref DateTime newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime result); + + /// + /// Required + /// + [Required] + public DateTime DateTimeAttr + { + get + { + DateTime value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset oldValue, ref DateTimeOffset newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset result); + + /// + /// Required + /// + [Required] + public DateTimeOffset DateTimeOffsetAttr + { + get + { + DateTimeOffset value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal oldValue, ref decimal newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal result); + + /// + /// Required + /// + [Required] + public decimal DecimalAttr + { + get + { + decimal value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double oldValue, ref double newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double result); + + /// + /// Required + /// + [Required] + public double DoubleAttr + { + get + { + double value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid oldValue, ref Guid newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid result); + + /// + /// Required + /// + [Required] + public Guid GuidAttr + { + get + { + Guid value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short oldValue, ref short newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short result); + + /// + /// Required + /// + [Required] + public short Int16Attr + { + get + { + short value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int result); + + /// + /// Required + /// + [Required] + public int Int32Attr + { + get + { + int value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long oldValue, ref long newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long result); + + /// + /// Required + /// + [Required] + public long Int64Attr + { + get + { + long value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single oldValue, ref Single newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single result); + + /// + /// Required + /// + [Required] + public Single SingleAttr + { + get + { + Single value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + /// + /// Required + /// + [Required] + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan oldValue, ref TimeSpan newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan result); + + /// + /// Required + /// + [Required] + public TimeSpan TimeAttr + { + get + { + TimeSpan value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class AllPropertyTypesOptional + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesOptional() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesOptional CreateAllPropertyTypesOptionalUnsafe() + { + return new AllPropertyTypesOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public AllPropertyTypesOptional(int id1) + { + this.Id1 = id1; + + this.OwnedType = new global::Testing.OwnedType(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static AllPropertyTypesOptional Create(int id1) + { + return new AllPropertyTypesOptional(id1); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool? _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool? oldValue, ref bool? newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool? result); + + public bool? BooleanAttr + { + get + { + bool? value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool? oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte? _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte? oldValue, ref byte? newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte? result); + + public byte? ByteAttr + { + get + { + byte? value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte? oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime? _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime? oldValue, ref DateTime? newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime? result); + + public DateTime? DateTimeAttr + { + get + { + DateTime? value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime? oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset? _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset? oldValue, ref DateTimeOffset? newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset? result); + + public DateTimeOffset? DateTimeOffsetAttr + { + get + { + DateTimeOffset? value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset? oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal? _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal? oldValue, ref decimal? newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal? result); + + public decimal? DecimalAttr + { + get + { + decimal? value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal? oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double? _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double? oldValue, ref double? newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double? result); + + public double? DoubleAttr + { + get + { + double? value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double? oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid? _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid? oldValue, ref Guid? newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid? result); + + public Guid? GuidAttr + { + get + { + Guid? value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid? oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short? _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short? oldValue, ref short? newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short? result); + + public short? Int16Attr + { + get + { + short? value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short? oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int? _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int? oldValue, ref int? newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int? result); + + public int? Int32Attr + { + get + { + int? value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int? oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long? _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long? oldValue, ref long? newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long? result); + + public long? Int64Attr + { + get + { + long? value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long? oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single? _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single? oldValue, ref Single? newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single? result); + + public Single? SingleAttr + { + get + { + Single? value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single? oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan? _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan? oldValue, ref TimeSpan? newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan? result); + + public TimeSpan? TimeAttr + { + get + { + TimeSpan? value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan? oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + /// + /// Backing field for Id1 + /// + internal int _id1; + /// + /// When provided in a partial class, allows value of Id1 to be changed before setting. + /// + partial void SetId1(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id1 to be changed before returning. + /// + partial void GetId1(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id1 + { + get + { + int value = _id1; + GetId1(ref value); + return (_id1 = value); + } + set + { + int oldValue = _id1; + SetId1(oldValue, ref value); + if (oldValue != value) + { + _id1 = value; + } + } + } + + /// + /// Concurrency token + /// + [Timestamp] + public Byte[] Timestamp { get; set; } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + public virtual global::Testing.OwnedType OwnedType { get; set; } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentRequired + { + partial void Init(); + + /// + /// Default constructor + /// + public UParentRequired() + { + UChildCollection = new System.Collections.Generic.HashSet(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired { get; set; } + + public virtual ICollection UChildCollection { get; private set; } + + public virtual global::Testing.UChild UChildOptional { get; set; } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentOptional: global::Testing.HiddenEntity + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentOptional(): base() + { + PropertyInChild = "hello"; + UChildCollection = new System.Collections.Generic.HashSet(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentOptional CreateUParentOptionalUnsafe() + { + return new UParentOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentOptional(global::Testing.UChild uchildrequired) + { + this.PropertyInChild = "hello"; + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + this.UChildCollection = new System.Collections.Generic.HashSet(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentOptional Create(global::Testing.UChild uchildrequired) + { + return new UParentOptional(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for PropertyInChild + /// + protected string _propertyInChild; + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before setting. + /// + partial void SetPropertyInChild(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before returning. + /// + partial void GetPropertyInChild(ref string result); + + /// + /// Default value = "hello" + /// + public string PropertyInChild + { + get + { + string value = _propertyInChild; + GetPropertyInChild(ref value); + return (_propertyInChild = value); + } + set + { + string oldValue = _propertyInChild; + SetPropertyInChild(oldValue, ref value); + if (oldValue != value) + { + _propertyInChild = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + public virtual global::Testing.UChild UChildOptional { get; set; } + + public virtual ICollection UChildCollection { get; private set; } + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired { get; set; } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentCollection + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentCollection() + { + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentCollection CreateUParentCollectionUnsafe() + { + return new UParentCollection(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentCollection(global::Testing.UChild uchildrequired) + { + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentCollection Create(global::Testing.UChild uchildrequired) + { + return new UParentCollection(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired { get; set; } + + public virtual global::Testing.UChild UChildOptional { get; set; } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UChild + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UChild() + { + // NOTE: This class has one-to-one associations with UChild. + // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other. + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UChild CreateUChildUnsafe() + { + return new UChild(); + } + + /// + /// Public constructor with required data + /// diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Context/AllFeatureModel.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Context/AllFeatureModel.generated.cs index d525915fb..8d7bc8786 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Context/AllFeatureModel.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Context/AllFeatureModel.generated.cs @@ -76,7 +76,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().ToTable("AllPropertyTypesOptionals").HasKey(t => new { t.Id, t.Id1 }); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.BinaryAttr).HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.BooleanAttr).HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.ByteAttr).HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); @@ -91,76 +91,76 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.SingleAttr).HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.StringAttr).HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.TimeAttr).HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Id1).IsRequired().HasField("_id1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever(); + modelBuilder.Entity().Property(t => t.Id1).HasField("_id1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever().IsRequired(); modelBuilder.Entity().Property("Timestamp").IsConcurrencyToken(); modelBuilder.Entity().OwnsOne(p => p.OwnedType).Property(p => p.SingleAttr); modelBuilder.Entity().ToTable("AllPropertyTypesRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().Property(t => t.BinaryAttr).IsRequired().HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.BooleanAttr).IsRequired().HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.ByteAttr).IsRequired().HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DateTimeAttr).IsRequired().HasField("_dateTimeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DateTimeOffsetAttr).IsRequired().HasField("_dateTimeOffsetAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DecimalAttr).IsRequired().HasField("_decimalAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DoubleAttr).IsRequired().HasField("_doubleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.GuidAttr).IsRequired().HasField("_guidAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int16Attr).IsRequired().HasField("_int16Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int32Attr).IsRequired().HasField("_int32Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int64Attr).IsRequired().HasField("_int64Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.SingleAttr).IsRequired().HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.StringAttr).IsRequired().HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.TimeAttr).IsRequired().HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().Property(t => t.BinaryAttr).HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.BooleanAttr).HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.ByteAttr).HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DateTimeAttr).HasField("_dateTimeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DateTimeOffsetAttr).HasField("_dateTimeOffsetAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DecimalAttr).HasField("_decimalAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DoubleAttr).HasField("_doubleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.GuidAttr).HasField("_guidAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int16Attr).HasField("_int16Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int32Attr).HasField("_int32Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int64Attr).HasField("_int64Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.SingleAttr).HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.StringAttr).HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.TimeAttr).HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().ToTable("BaseClassWithRequiredProperties").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().Property(t => t.Property0).IsRequired().HasField("_property0").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().Property(t => t.Property0).HasField("_property0").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().ToTable("BChilds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("BParentCollections").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithMany(p => p.BParentCollection).HasForeignKey("BChildRequiredId"); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithMany(p => p.BParentCollection_2).HasForeignKey("BChildOptionalId"); modelBuilder.Entity().ToTable("BParentOptionals").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentOptional).HasForeignKey("BParentOptional", "BChildRequiredId"); modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentOptional_1).HasForeignKey("BParentOptional_1Id"); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentOptional_2).HasForeignKey("BChild", "BParentOptional_2Id"); modelBuilder.Entity().ToTable("BParentRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentRequired).HasForeignKey("BChild", "BParentRequiredId").IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentRequired_1).HasForeignKey("BChild", "BParentRequired_1Id"); modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentRequired_2).HasForeignKey("BParentRequired_2Id").IsRequired(); modelBuilder.Entity().ToTable("Children").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasMany(p => p.Children).WithOne(p => p.Parent).HasForeignKey("ParentId").IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Property1).IsRequired().HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("HiddenEntities").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("Masters").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasMany(p => p.Children).WithOne().HasForeignKey("Master_Children_Id").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasMany(p => p.Children).WithOne().HasForeignKey("MasterChildrenId").IsRequired(); modelBuilder.Owned(); modelBuilder.Entity().ToTable("ParserTests").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.name1).HasField("_name1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.name2).HasField("_name2").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.name3).HasField("_name3").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); @@ -181,26 +181,26 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.name18).HasField("_name18").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("RenamedColumns").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasColumnName("Foo").HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasColumnName("Foo").HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("UChilds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("UParentCollections").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.UChildRequired).WithMany().HasForeignKey("UChildRequiredId"); modelBuilder.Entity().HasOne(p => p.UChildOptional).WithMany().HasForeignKey("UChildOptionalId"); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentOptional_UChildOptional_Id"); - modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentOptional_UChildCollection_Id"); + modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentOptionalUChildOptionalId"); + modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentOptionalUChildCollectionId"); modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UParentOptional", "UChildRequiredId"); modelBuilder.Entity().ToTable("UParentRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UChild", "UParentRequired_UChildRequired_Id"); - modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentRequired_UChildCollection_Id").IsRequired(); - modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentRequired_UChildOptional_Id").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UChild", "UParentRequiredUChildRequiredId"); + modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentRequiredUChildCollectionId").IsRequired(); + modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentRequiredUChildOptionalId").IsRequired(); OnModelCreatedImpl(modelBuilder); } diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/AbstractBaseClass.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/AbstractBaseClass.generated.cs index f506f1cf1..8118b33b2 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/AbstractBaseClass.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/AbstractBaseClass.generated.cs @@ -39,7 +39,6 @@ protected AbstractBaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/AllPropertyTypesOptional.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/AllPropertyTypesOptional.generated.cs index 735d795dd..2491f19b2 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/AllPropertyTypesOptional.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/AllPropertyTypesOptional.generated.cs @@ -47,7 +47,6 @@ public AllPropertyTypesOptional(int id1) this.Id1 = id1; this.OwnedType = new global::Testing.OwnedType(); - Init(); } @@ -90,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/AllPropertyTypesRequired.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/AllPropertyTypesRequired.generated.cs index 965a5474b..bf799d306 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/AllPropertyTypesRequired.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/AllPropertyTypesRequired.generated.cs @@ -86,7 +86,6 @@ public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteat this.TimeAttr = timeattr; - Init(); } @@ -142,7 +141,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BChild.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BChild.generated.cs index 802976967..7c03d3986 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BChild.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BChild.generated.cs @@ -59,13 +59,14 @@ public BChild(global::Testing.BParentRequired bparentrequired, global::Testing.B if (bparentrequired == null) throw new ArgumentNullException(nameof(bparentrequired)); this.BParentRequired = bparentrequired; + bparentrequired.BChildOptional = this; if (bparentrequired_2 == null) throw new ArgumentNullException(nameof(bparentrequired_2)); this.BParentRequired_2 = bparentrequired_2; + bparentrequired_2.BChildCollection.Add(this); this.BParentCollection = new System.Collections.Generic.HashSet(); this.BParentCollection_2 = new System.Collections.Generic.HashSet(); - Init(); } @@ -109,7 +110,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BParentCollection.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BParentCollection.generated.cs index 8634a21a5..a5013b12f 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BParentCollection.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BParentCollection.generated.cs @@ -48,7 +48,7 @@ public BParentCollection(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; - + bchildrequired.BParentCollection.Add(this); Init(); } @@ -92,7 +92,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BParentOptional.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BParentOptional.generated.cs index 84d56e0c6..226bb166d 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BParentOptional.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BParentOptional.generated.cs @@ -49,9 +49,9 @@ public BParentOptional(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; + bchildrequired.BParentOptional = this; this.BChildCollection = new System.Collections.Generic.HashSet(); - Init(); } @@ -94,7 +94,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BParentRequired.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BParentRequired.generated.cs index 76f2f8256..f4e98dd22 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BParentRequired.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BParentRequired.generated.cs @@ -63,7 +63,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BaseClass.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BaseClass.generated.cs index 1e11e199e..ab595e96c 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BaseClass.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BaseClass.generated.cs @@ -47,7 +47,6 @@ public BaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BaseClassWithRequiredProperties.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BaseClassWithRequiredProperties.generated.cs index bb337a79e..557698cc4 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BaseClassWithRequiredProperties.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/BaseClassWithRequiredProperties.generated.cs @@ -47,7 +47,6 @@ public BaseClassWithRequiredProperties(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } @@ -90,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/Child.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/Child.generated.cs index 65018f57c..068995121 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/Child.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/Child.generated.cs @@ -50,12 +50,12 @@ public Child(global::Testing.Child parent, global::Testing.Master _master0) { if (parent == null) throw new ArgumentNullException(nameof(parent)); this.Parent = parent; + parent.Children.Add(this); if (_master0 == null) throw new ArgumentNullException(nameof(_master0)); _master0.Children.Add(this); this.Children = new System.Collections.Generic.HashSet(); - Init(); } @@ -99,7 +99,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/ConcreteDerivedClass.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/ConcreteDerivedClass.generated.cs index cee4e6783..b05619dd1 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/ConcreteDerivedClass.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/ConcreteDerivedClass.generated.cs @@ -47,7 +47,6 @@ public ConcreteDerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs index b3fa04fdb..84cd0bc5c 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs @@ -51,7 +51,6 @@ public ConcreteDerivedClassWithRequiredProperties(string property1, string prope if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/DerivedClass.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/DerivedClass.generated.cs index 33e54b6e6..59dd6f39f 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/DerivedClass.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/DerivedClass.generated.cs @@ -47,7 +47,6 @@ public DerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/HiddenEntity.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/HiddenEntity.generated.cs index caa5dcc02..3ae611794 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/HiddenEntity.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/HiddenEntity.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/Master.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/Master.generated.cs index 4d7d84ee6..c5a1c9983 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/Master.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/Master.generated.cs @@ -62,7 +62,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/OwnedType.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/OwnedType.generated.cs index 356934d5a..66af3d729 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/OwnedType.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/OwnedType.generated.cs @@ -39,7 +39,6 @@ public OwnedType(global::Testing.AllPropertyTypesOptional _allpropertytypesoptio if (_allpropertytypesoptional0 == null) throw new ArgumentNullException(nameof(_allpropertytypesoptional0)); _allpropertytypesoptional0.OwnedType = this; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/ParserTest.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/ParserTest.generated.cs index 261469691..aa8ab86c0 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/ParserTest.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/ParserTest.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/RenamedColumn.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/RenamedColumn.generated.cs index e12f1a4c5..97af66423 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/RenamedColumn.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/RenamedColumn.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/UChild.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/UChild.generated.cs index bc67ba3d7..9b1d7572d 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/UChild.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/UChild.generated.cs @@ -57,7 +57,6 @@ public UChild(global::Testing.UParentRequired _uparentrequired1, global::Testing if (_uparentrequired2 == null) throw new ArgumentNullException(nameof(_uparentrequired2)); _uparentrequired2.UChildOptional = this; - Init(); } @@ -101,7 +100,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/UParentCollection.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/UParentCollection.generated.cs index 69a64be0c..c79ae968c 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/UParentCollection.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/UParentCollection.generated.cs @@ -49,7 +49,6 @@ public UParentCollection(global::Testing.UChild uchildrequired) if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); this.UChildRequired = uchildrequired; - Init(); } @@ -92,7 +91,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/UParentOptional.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/UParentOptional.generated.cs index aec715adc..4f7f5391b 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/UParentOptional.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/UParentOptional.generated.cs @@ -53,7 +53,6 @@ public UParentOptional(global::Testing.UChild uchildrequired) this.UChildRequired = uchildrequired; this.UChildCollection = new System.Collections.Generic.HashSet(); - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/UParentRequired.generated.cs b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/UParentRequired.generated.cs index 13eb5157b..ee8c9c48e 100644 --- a/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/UParentRequired.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetFramework/Generated/Entities/UParentRequired.generated.cs @@ -63,7 +63,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/AllFeatureModel.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/AllFeatureModel.cs index 6153a7d78..47021ebc9 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/AllFeatureModel.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/AllFeatureModel.cs @@ -1 +1,1851 @@  +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class AllPropertyTypesRequired + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesRequired() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesRequired CreateAllPropertyTypesRequiredUnsafe() + { + return new AllPropertyTypesRequired(); + } + + /// + /// Public constructor with required data + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, string stringattr, TimeSpan timeattr) + { + this.BinaryAttr = binaryattr; + + this.BooleanAttr = booleanattr; + + this.ByteAttr = byteattr; + + this.DateTimeAttr = datetimeattr; + + this.DateTimeOffsetAttr = datetimeoffsetattr; + + this.DecimalAttr = decimalattr; + + this.DoubleAttr = doubleattr; + + this.GuidAttr = guidattr; + + this.Int16Attr = int16attr; + + this.Int32Attr = int32attr; + + this.Int64Attr = int64attr; + + this.SingleAttr = singleattr; + + if (string.IsNullOrEmpty(stringattr)) throw new ArgumentNullException(nameof(stringattr)); + this.StringAttr = stringattr; + + this.TimeAttr = timeattr; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static AllPropertyTypesRequired Create(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, string stringattr, TimeSpan timeattr) + { + return new AllPropertyTypesRequired(binaryattr, booleanattr, byteattr, datetimeattr, datetimeoffsetattr, decimalattr, doubleattr, guidattr, int16attr, int32attr, int64attr, singleattr, stringattr, timeattr); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + /// + /// Required + /// + [Required] + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool oldValue, ref bool newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool result); + + /// + /// Required + /// + [Required] + public bool BooleanAttr + { + get + { + bool value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte oldValue, ref byte newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte result); + + /// + /// Required + /// + [Required] + public byte ByteAttr + { + get + { + byte value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime oldValue, ref DateTime newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime result); + + /// + /// Required + /// + [Required] + public DateTime DateTimeAttr + { + get + { + DateTime value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset oldValue, ref DateTimeOffset newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset result); + + /// + /// Required + /// + [Required] + public DateTimeOffset DateTimeOffsetAttr + { + get + { + DateTimeOffset value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal oldValue, ref decimal newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal result); + + /// + /// Required + /// + [Required] + public decimal DecimalAttr + { + get + { + decimal value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double oldValue, ref double newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double result); + + /// + /// Required + /// + [Required] + public double DoubleAttr + { + get + { + double value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid oldValue, ref Guid newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid result); + + /// + /// Required + /// + [Required] + public Guid GuidAttr + { + get + { + Guid value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short oldValue, ref short newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short result); + + /// + /// Required + /// + [Required] + public short Int16Attr + { + get + { + short value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int result); + + /// + /// Required + /// + [Required] + public int Int32Attr + { + get + { + int value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long oldValue, ref long newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long result); + + /// + /// Required + /// + [Required] + public long Int64Attr + { + get + { + long value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single oldValue, ref Single newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single result); + + /// + /// Required + /// + [Required] + public Single SingleAttr + { + get + { + Single value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + /// + /// Required + /// + [Required] + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan oldValue, ref TimeSpan newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan result); + + /// + /// Required + /// + [Required] + public TimeSpan TimeAttr + { + get + { + TimeSpan value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class AllPropertyTypesOptional + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesOptional() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesOptional CreateAllPropertyTypesOptionalUnsafe() + { + return new AllPropertyTypesOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public AllPropertyTypesOptional(int id1) + { + this.Id1 = id1; + + this.OwnedType = new global::Testing.OwnedType(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static AllPropertyTypesOptional Create(int id1) + { + return new AllPropertyTypesOptional(id1); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool? _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool? oldValue, ref bool? newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool? result); + + public bool? BooleanAttr + { + get + { + bool? value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool? oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte? _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte? oldValue, ref byte? newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte? result); + + public byte? ByteAttr + { + get + { + byte? value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte? oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime? _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime? oldValue, ref DateTime? newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime? result); + + public DateTime? DateTimeAttr + { + get + { + DateTime? value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime? oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset? _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset? oldValue, ref DateTimeOffset? newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset? result); + + public DateTimeOffset? DateTimeOffsetAttr + { + get + { + DateTimeOffset? value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset? oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal? _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal? oldValue, ref decimal? newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal? result); + + public decimal? DecimalAttr + { + get + { + decimal? value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal? oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double? _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double? oldValue, ref double? newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double? result); + + public double? DoubleAttr + { + get + { + double? value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double? oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid? _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid? oldValue, ref Guid? newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid? result); + + public Guid? GuidAttr + { + get + { + Guid? value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid? oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short? _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short? oldValue, ref short? newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short? result); + + public short? Int16Attr + { + get + { + short? value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short? oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int? _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int? oldValue, ref int? newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int? result); + + public int? Int32Attr + { + get + { + int? value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int? oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long? _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long? oldValue, ref long? newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long? result); + + public long? Int64Attr + { + get + { + long? value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long? oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single? _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single? oldValue, ref Single? newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single? result); + + public Single? SingleAttr + { + get + { + Single? value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single? oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan? _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan? oldValue, ref TimeSpan? newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan? result); + + public TimeSpan? TimeAttr + { + get + { + TimeSpan? value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan? oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + /// + /// Backing field for Id1 + /// + internal int _id1; + /// + /// When provided in a partial class, allows value of Id1 to be changed before setting. + /// + partial void SetId1(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id1 to be changed before returning. + /// + partial void GetId1(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id1 + { + get + { + int value = _id1; + GetId1(ref value); + return (_id1 = value); + } + set + { + int oldValue = _id1; + SetId1(oldValue, ref value); + if (oldValue != value) + { + _id1 = value; + } + } + } + + /// + /// Concurrency token + /// + [Timestamp] + public Byte[] Timestamp { get; set; } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for OwnedType + /// + protected global::Testing.OwnedType _ownedType; + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before setting. + /// + partial void SetOwnedType(global::Testing.OwnedType oldValue, ref global::Testing.OwnedType newValue); + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before returning. + /// + partial void GetOwnedType(ref global::Testing.OwnedType result); + + public virtual global::Testing.OwnedType OwnedType + { + get + { + global::Testing.OwnedType value = _ownedType; + GetOwnedType(ref value); + return (_ownedType = value); + } + set + { + global::Testing.OwnedType oldValue = _ownedType; + SetOwnedType(oldValue, ref value); + if (oldValue != value) + { + _ownedType = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentRequired + { + partial void Init(); + + /// + /// Default constructor + /// + public UParentRequired() + { + UChildCollection = new System.Collections.Generic.HashSet(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentOptional: global::Testing.HiddenEntity + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentOptional(): base() + { + PropertyInChild = "hello"; + UChildCollection = new System.Collections.Generic.HashSet(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentOptional CreateUParentOptionalUnsafe() + { + return new UParentOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentOptional(global::Testing.UChild uchildrequired) + { + this.PropertyInChild = "hello"; + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + this.UChildCollection = new System.Collections.Generic.HashSet(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentOptional Create(global::Testing.UChild uchildrequired) + { + return new UParentOptional(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for PropertyInChild + /// + protected string _propertyInChild; + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before setting. + /// + partial void SetPropertyInChild(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before returning. + /// + partial void GetPropertyInChild(ref string result); + + /// + /// Default value = "hello" + /// + public string PropertyInChild + { + get + { + string value = _propertyInChild; + GetPropertyInChild(ref value); + return (_propertyInChild = value); + } + set + { + string oldValue = _propertyInChild; + SetPropertyInChild(oldValue, ref value); + if (oldValue != value) + { + _propertyInChild = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentCollection + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentCollection() + { + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentCollection CreateUParentCollectionUnsafe() + { + return new UParentCollection(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentCollection(global::Testing.UChild uchildrequired) + { + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentCollection Create(global::Testing.UChild uchildrequired) + { + return new UParentCollection(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UChild + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UChild() + { + // NOTE: This class has one-to-one associations with UChild. + // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other. + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UChild CreateUChildUnsafe() + { + return new UChild(); + } + + /// + /// Public constructor with required data + /// diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Context/AllFeatureModel.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Context/AllFeatureModel.generated.cs index 8b4ef3701..b58a5a1b4 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Context/AllFeatureModel.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Context/AllFeatureModel.generated.cs @@ -76,7 +76,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().ToTable("AllPropertyTypesOptionals").HasKey(t => new { t.Id, t.Id1 }); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.BinaryAttr).HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.BooleanAttr).HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.ByteAttr).HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); @@ -91,76 +91,76 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.SingleAttr).HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.StringAttr).HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.TimeAttr).HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Id1).IsRequired().HasField("_id1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever(); + modelBuilder.Entity().Property(t => t.Id1).HasField("_id1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever().IsRequired(); modelBuilder.Entity().Property("Timestamp").IsConcurrencyToken(); modelBuilder.Entity().OwnsOne(p => p.OwnedType).Property(p => p.SingleAttr); modelBuilder.Entity().ToTable("AllPropertyTypesRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().Property(t => t.BinaryAttr).IsRequired().HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.BooleanAttr).IsRequired().HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.ByteAttr).IsRequired().HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DateTimeAttr).IsRequired().HasField("_dateTimeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DateTimeOffsetAttr).IsRequired().HasField("_dateTimeOffsetAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DecimalAttr).IsRequired().HasField("_decimalAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DoubleAttr).IsRequired().HasField("_doubleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.GuidAttr).IsRequired().HasField("_guidAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int16Attr).IsRequired().HasField("_int16Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int32Attr).IsRequired().HasField("_int32Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int64Attr).IsRequired().HasField("_int64Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.SingleAttr).IsRequired().HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.StringAttr).IsRequired().HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.TimeAttr).IsRequired().HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().Property(t => t.BinaryAttr).HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.BooleanAttr).HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.ByteAttr).HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DateTimeAttr).HasField("_dateTimeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DateTimeOffsetAttr).HasField("_dateTimeOffsetAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DecimalAttr).HasField("_decimalAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DoubleAttr).HasField("_doubleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.GuidAttr).HasField("_guidAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int16Attr).HasField("_int16Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int32Attr).HasField("_int32Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int64Attr).HasField("_int64Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.SingleAttr).HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.StringAttr).HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.TimeAttr).HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().ToTable("BaseClassWithRequiredProperties").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().Property(t => t.Property0).IsRequired().HasField("_property0").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().Property(t => t.Property0).HasField("_property0").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().ToTable("BChilds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("BParentCollections").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithMany(p => p.BParentCollection).HasForeignKey("BChildRequiredId"); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithMany(p => p.BParentCollection_2).HasForeignKey("BChildOptionalId"); modelBuilder.Entity().ToTable("BParentOptionals").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentOptional).HasForeignKey("BParentOptional", "BChildRequiredId"); modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentOptional_1).HasForeignKey("BParentOptional_1Id"); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentOptional_2).HasForeignKey("BChild", "BParentOptional_2Id"); modelBuilder.Entity().ToTable("BParentRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentRequired).HasForeignKey("BChild", "BParentRequiredId").IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentRequired_1).HasForeignKey("BChild", "BParentRequired_1Id"); modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentRequired_2).HasForeignKey("BParentRequired_2Id").IsRequired(); modelBuilder.Entity().ToTable("Children").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasMany(p => p.Children).WithOne(p => p.Parent).HasForeignKey("ParentId").IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Property1).IsRequired().HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("HiddenEntities").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("Masters").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasMany(p => p.Children).WithOne().HasForeignKey("Master_Children_Id").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasMany(p => p.Children).WithOne().HasForeignKey("MasterChildrenId").IsRequired(); modelBuilder.Owned(); modelBuilder.Entity().ToTable("ParserTests").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.name1).HasField("_name1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.name2).HasField("_name2").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.name3).HasField("_name3").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); @@ -181,26 +181,26 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.name18).HasField("_name18").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("RenamedColumns").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasColumnName("Foo").HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasColumnName("Foo").HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("UChilds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("UParentCollections").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.UChildRequired).WithMany().HasForeignKey("UChildRequiredId"); modelBuilder.Entity().HasOne(p => p.UChildOptional).WithMany().HasForeignKey("UChildOptionalId"); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentOptional_UChildOptional_Id"); - modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentOptional_UChildCollection_Id"); + modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentOptionalUChildOptionalId"); + modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentOptionalUChildCollectionId"); modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UParentOptional", "UChildRequiredId"); modelBuilder.Entity().ToTable("UParentRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UChild", "UParentRequired_UChildRequired_Id"); - modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentRequired_UChildCollection_Id").IsRequired(); - modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentRequired_UChildOptional_Id").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UChild", "UParentRequiredUChildRequiredId"); + modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentRequiredUChildCollectionId").IsRequired(); + modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentRequiredUChildOptionalId").IsRequired(); OnModelCreatedImpl(modelBuilder); } diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/AbstractBaseClass.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/AbstractBaseClass.generated.cs index f506f1cf1..8118b33b2 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/AbstractBaseClass.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/AbstractBaseClass.generated.cs @@ -39,7 +39,6 @@ protected AbstractBaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/AllPropertyTypesOptional.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/AllPropertyTypesOptional.generated.cs index a31e28272..4ed270044 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/AllPropertyTypesOptional.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/AllPropertyTypesOptional.generated.cs @@ -47,7 +47,6 @@ public AllPropertyTypesOptional(int id1) this.Id1 = id1; this.OwnedType = new global::Testing.OwnedType(); - Init(); } @@ -90,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -596,8 +595,19 @@ public int Id1 * Navigation properties *************************************************************************/ + /// + /// Backing field for OwnedType + /// protected global::Testing.OwnedType _ownedType; + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before setting. + /// partial void SetOwnedType(global::Testing.OwnedType oldValue, ref global::Testing.OwnedType newValue); + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before returning. + /// partial void GetOwnedType(ref global::Testing.OwnedType result); public virtual global::Testing.OwnedType OwnedType diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/AllPropertyTypesRequired.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/AllPropertyTypesRequired.generated.cs index 965a5474b..bf799d306 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/AllPropertyTypesRequired.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/AllPropertyTypesRequired.generated.cs @@ -86,7 +86,6 @@ public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteat this.TimeAttr = timeattr; - Init(); } @@ -142,7 +141,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BChild.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BChild.generated.cs index 802976967..7c03d3986 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BChild.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BChild.generated.cs @@ -59,13 +59,14 @@ public BChild(global::Testing.BParentRequired bparentrequired, global::Testing.B if (bparentrequired == null) throw new ArgumentNullException(nameof(bparentrequired)); this.BParentRequired = bparentrequired; + bparentrequired.BChildOptional = this; if (bparentrequired_2 == null) throw new ArgumentNullException(nameof(bparentrequired_2)); this.BParentRequired_2 = bparentrequired_2; + bparentrequired_2.BChildCollection.Add(this); this.BParentCollection = new System.Collections.Generic.HashSet(); this.BParentCollection_2 = new System.Collections.Generic.HashSet(); - Init(); } @@ -109,7 +110,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BParentCollection.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BParentCollection.generated.cs index af5faf66c..720d8ff41 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BParentCollection.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BParentCollection.generated.cs @@ -48,7 +48,7 @@ public BParentCollection(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; - + bchildrequired.BParentCollection.Add(this); Init(); } @@ -92,7 +92,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -107,8 +107,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -133,8 +144,19 @@ protected set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BParentOptional.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BParentOptional.generated.cs index 8c4093fa7..a3847a676 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BParentOptional.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BParentOptional.generated.cs @@ -49,9 +49,9 @@ public BParentOptional(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; + bchildrequired.BParentOptional = this; this.BChildCollection = new System.Collections.Generic.HashSet(); - Init(); } @@ -94,7 +94,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -109,8 +109,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -135,7 +146,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get @@ -148,8 +163,19 @@ private set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BParentRequired.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BParentRequired.generated.cs index e9d71bdd2..fab838807 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BParentRequired.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BParentRequired.generated.cs @@ -63,7 +63,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -78,8 +78,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional @@ -101,8 +112,19 @@ protected set } } + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -127,7 +149,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BaseClass.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BaseClass.generated.cs index 1e11e199e..ab595e96c 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BaseClass.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BaseClass.generated.cs @@ -47,7 +47,6 @@ public BaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BaseClassWithRequiredProperties.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BaseClassWithRequiredProperties.generated.cs index bb337a79e..557698cc4 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BaseClassWithRequiredProperties.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/BaseClassWithRequiredProperties.generated.cs @@ -47,7 +47,6 @@ public BaseClassWithRequiredProperties(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } @@ -90,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/Child.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/Child.generated.cs index 355e18745..de2ef22b8 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/Child.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/Child.generated.cs @@ -50,12 +50,12 @@ public Child(global::Testing.Child parent, global::Testing.Master _master0) { if (parent == null) throw new ArgumentNullException(nameof(parent)); this.Parent = parent; + parent.Children.Add(this); if (_master0 == null) throw new ArgumentNullException(nameof(_master0)); _master0.Children.Add(this); this.Children = new System.Collections.Generic.HashSet(); - Init(); } @@ -99,7 +99,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -114,7 +114,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/ConcreteDerivedClass.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/ConcreteDerivedClass.generated.cs index cee4e6783..b05619dd1 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/ConcreteDerivedClass.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/ConcreteDerivedClass.generated.cs @@ -47,7 +47,6 @@ public ConcreteDerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs index b3fa04fdb..84cd0bc5c 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs @@ -51,7 +51,6 @@ public ConcreteDerivedClassWithRequiredProperties(string property1, string prope if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/DerivedClass.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/DerivedClass.generated.cs index 33e54b6e6..59dd6f39f 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/DerivedClass.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/DerivedClass.generated.cs @@ -47,7 +47,6 @@ public DerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/HiddenEntity.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/HiddenEntity.generated.cs index caa5dcc02..3ae611794 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/HiddenEntity.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/HiddenEntity.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/Master.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/Master.generated.cs index fd5ed86b8..61807d30b 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/Master.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/Master.generated.cs @@ -62,7 +62,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -77,7 +77,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/OwnedType.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/OwnedType.generated.cs index 356934d5a..66af3d729 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/OwnedType.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/OwnedType.generated.cs @@ -39,7 +39,6 @@ public OwnedType(global::Testing.AllPropertyTypesOptional _allpropertytypesoptio if (_allpropertytypesoptional0 == null) throw new ArgumentNullException(nameof(_allpropertytypesoptional0)); _allpropertytypesoptional0.OwnedType = this; - Init(); } diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/ParserTest.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/ParserTest.generated.cs index 261469691..aa8ab86c0 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/ParserTest.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/ParserTest.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/RenamedColumn.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/RenamedColumn.generated.cs index e12f1a4c5..97af66423 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/RenamedColumn.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/RenamedColumn.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/UChild.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/UChild.generated.cs index bc67ba3d7..9b1d7572d 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/UChild.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/UChild.generated.cs @@ -57,7 +57,6 @@ public UChild(global::Testing.UParentRequired _uparentrequired1, global::Testing if (_uparentrequired2 == null) throw new ArgumentNullException(nameof(_uparentrequired2)); _uparentrequired2.UChildOptional = this; - Init(); } @@ -101,7 +100,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/UParentCollection.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/UParentCollection.generated.cs index b2fe3516b..2c7cd4500 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/UParentCollection.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/UParentCollection.generated.cs @@ -49,7 +49,6 @@ public UParentCollection(global::Testing.UChild uchildrequired) if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); this.UChildRequired = uchildrequired; - Init(); } @@ -92,7 +91,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -107,8 +106,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -133,8 +143,19 @@ protected set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/UParentOptional.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/UParentOptional.generated.cs index e27bf7bb8..f76725ae6 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/UParentOptional.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/UParentOptional.generated.cs @@ -53,7 +53,6 @@ public UParentOptional(global::Testing.UChild uchildrequired) this.UChildRequired = uchildrequired; this.UChildCollection = new System.Collections.Generic.HashSet(); - Init(); } @@ -109,8 +108,19 @@ public string PropertyInChild * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional @@ -132,7 +142,11 @@ public string PropertyInChild } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -145,8 +159,19 @@ private set } } + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// diff --git a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/UParentRequired.generated.cs b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/UParentRequired.generated.cs index be5063e5f..39ebd0f6a 100644 --- a/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/UParentRequired.generated.cs +++ b/src/Testing/EFCoreV2/EFCore2NetStandard/Generated/Entities/UParentRequired.generated.cs @@ -63,7 +63,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -78,8 +78,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -104,7 +115,11 @@ protected set } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -117,8 +132,19 @@ private set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/AllFeatureModel.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/AllFeatureModel.cs index 6153a7d78..47021ebc9 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/AllFeatureModel.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/AllFeatureModel.cs @@ -1 +1,1851 @@  +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class AllPropertyTypesRequired + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesRequired() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesRequired CreateAllPropertyTypesRequiredUnsafe() + { + return new AllPropertyTypesRequired(); + } + + /// + /// Public constructor with required data + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, string stringattr, TimeSpan timeattr) + { + this.BinaryAttr = binaryattr; + + this.BooleanAttr = booleanattr; + + this.ByteAttr = byteattr; + + this.DateTimeAttr = datetimeattr; + + this.DateTimeOffsetAttr = datetimeoffsetattr; + + this.DecimalAttr = decimalattr; + + this.DoubleAttr = doubleattr; + + this.GuidAttr = guidattr; + + this.Int16Attr = int16attr; + + this.Int32Attr = int32attr; + + this.Int64Attr = int64attr; + + this.SingleAttr = singleattr; + + if (string.IsNullOrEmpty(stringattr)) throw new ArgumentNullException(nameof(stringattr)); + this.StringAttr = stringattr; + + this.TimeAttr = timeattr; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static AllPropertyTypesRequired Create(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, string stringattr, TimeSpan timeattr) + { + return new AllPropertyTypesRequired(binaryattr, booleanattr, byteattr, datetimeattr, datetimeoffsetattr, decimalattr, doubleattr, guidattr, int16attr, int32attr, int64attr, singleattr, stringattr, timeattr); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + /// + /// Required + /// + [Required] + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool oldValue, ref bool newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool result); + + /// + /// Required + /// + [Required] + public bool BooleanAttr + { + get + { + bool value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte oldValue, ref byte newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte result); + + /// + /// Required + /// + [Required] + public byte ByteAttr + { + get + { + byte value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime oldValue, ref DateTime newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime result); + + /// + /// Required + /// + [Required] + public DateTime DateTimeAttr + { + get + { + DateTime value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset oldValue, ref DateTimeOffset newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset result); + + /// + /// Required + /// + [Required] + public DateTimeOffset DateTimeOffsetAttr + { + get + { + DateTimeOffset value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal oldValue, ref decimal newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal result); + + /// + /// Required + /// + [Required] + public decimal DecimalAttr + { + get + { + decimal value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double oldValue, ref double newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double result); + + /// + /// Required + /// + [Required] + public double DoubleAttr + { + get + { + double value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid oldValue, ref Guid newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid result); + + /// + /// Required + /// + [Required] + public Guid GuidAttr + { + get + { + Guid value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short oldValue, ref short newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short result); + + /// + /// Required + /// + [Required] + public short Int16Attr + { + get + { + short value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int result); + + /// + /// Required + /// + [Required] + public int Int32Attr + { + get + { + int value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long oldValue, ref long newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long result); + + /// + /// Required + /// + [Required] + public long Int64Attr + { + get + { + long value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single oldValue, ref Single newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single result); + + /// + /// Required + /// + [Required] + public Single SingleAttr + { + get + { + Single value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + /// + /// Required + /// + [Required] + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan oldValue, ref TimeSpan newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan result); + + /// + /// Required + /// + [Required] + public TimeSpan TimeAttr + { + get + { + TimeSpan value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class AllPropertyTypesOptional + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesOptional() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesOptional CreateAllPropertyTypesOptionalUnsafe() + { + return new AllPropertyTypesOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public AllPropertyTypesOptional(int id1) + { + this.Id1 = id1; + + this.OwnedType = new global::Testing.OwnedType(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static AllPropertyTypesOptional Create(int id1) + { + return new AllPropertyTypesOptional(id1); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool? _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool? oldValue, ref bool? newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool? result); + + public bool? BooleanAttr + { + get + { + bool? value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool? oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte? _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte? oldValue, ref byte? newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte? result); + + public byte? ByteAttr + { + get + { + byte? value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte? oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime? _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime? oldValue, ref DateTime? newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime? result); + + public DateTime? DateTimeAttr + { + get + { + DateTime? value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime? oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset? _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset? oldValue, ref DateTimeOffset? newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset? result); + + public DateTimeOffset? DateTimeOffsetAttr + { + get + { + DateTimeOffset? value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset? oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal? _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal? oldValue, ref decimal? newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal? result); + + public decimal? DecimalAttr + { + get + { + decimal? value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal? oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double? _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double? oldValue, ref double? newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double? result); + + public double? DoubleAttr + { + get + { + double? value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double? oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid? _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid? oldValue, ref Guid? newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid? result); + + public Guid? GuidAttr + { + get + { + Guid? value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid? oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short? _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short? oldValue, ref short? newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short? result); + + public short? Int16Attr + { + get + { + short? value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short? oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int? _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int? oldValue, ref int? newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int? result); + + public int? Int32Attr + { + get + { + int? value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int? oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long? _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long? oldValue, ref long? newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long? result); + + public long? Int64Attr + { + get + { + long? value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long? oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single? _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single? oldValue, ref Single? newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single? result); + + public Single? SingleAttr + { + get + { + Single? value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single? oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan? _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan? oldValue, ref TimeSpan? newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan? result); + + public TimeSpan? TimeAttr + { + get + { + TimeSpan? value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan? oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + /// + /// Backing field for Id1 + /// + internal int _id1; + /// + /// When provided in a partial class, allows value of Id1 to be changed before setting. + /// + partial void SetId1(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id1 to be changed before returning. + /// + partial void GetId1(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id1 + { + get + { + int value = _id1; + GetId1(ref value); + return (_id1 = value); + } + set + { + int oldValue = _id1; + SetId1(oldValue, ref value); + if (oldValue != value) + { + _id1 = value; + } + } + } + + /// + /// Concurrency token + /// + [Timestamp] + public Byte[] Timestamp { get; set; } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for OwnedType + /// + protected global::Testing.OwnedType _ownedType; + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before setting. + /// + partial void SetOwnedType(global::Testing.OwnedType oldValue, ref global::Testing.OwnedType newValue); + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before returning. + /// + partial void GetOwnedType(ref global::Testing.OwnedType result); + + public virtual global::Testing.OwnedType OwnedType + { + get + { + global::Testing.OwnedType value = _ownedType; + GetOwnedType(ref value); + return (_ownedType = value); + } + set + { + global::Testing.OwnedType oldValue = _ownedType; + SetOwnedType(oldValue, ref value); + if (oldValue != value) + { + _ownedType = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentRequired + { + partial void Init(); + + /// + /// Default constructor + /// + public UParentRequired() + { + UChildCollection = new System.Collections.Generic.HashSet(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentOptional: global::Testing.HiddenEntity + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentOptional(): base() + { + PropertyInChild = "hello"; + UChildCollection = new System.Collections.Generic.HashSet(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentOptional CreateUParentOptionalUnsafe() + { + return new UParentOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentOptional(global::Testing.UChild uchildrequired) + { + this.PropertyInChild = "hello"; + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + this.UChildCollection = new System.Collections.Generic.HashSet(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentOptional Create(global::Testing.UChild uchildrequired) + { + return new UParentOptional(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for PropertyInChild + /// + protected string _propertyInChild; + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before setting. + /// + partial void SetPropertyInChild(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before returning. + /// + partial void GetPropertyInChild(ref string result); + + /// + /// Default value = "hello" + /// + public string PropertyInChild + { + get + { + string value = _propertyInChild; + GetPropertyInChild(ref value); + return (_propertyInChild = value); + } + set + { + string oldValue = _propertyInChild; + SetPropertyInChild(oldValue, ref value); + if (oldValue != value) + { + _propertyInChild = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentCollection + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentCollection() + { + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentCollection CreateUParentCollectionUnsafe() + { + return new UParentCollection(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentCollection(global::Testing.UChild uchildrequired) + { + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentCollection Create(global::Testing.UChild uchildrequired) + { + return new UParentCollection(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UChild + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UChild() + { + // NOTE: This class has one-to-one associations with UChild. + // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other. + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UChild CreateUChildUnsafe() + { + return new UChild(); + } + + /// + /// Public constructor with required data + /// diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Context/AllFeatureModel.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Context/AllFeatureModel.generated.cs index 8b4ef3701..5299ec2a6 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Context/AllFeatureModel.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Context/AllFeatureModel.generated.cs @@ -76,7 +76,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().ToTable("AllPropertyTypesOptionals").HasKey(t => new { t.Id, t.Id1 }); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.BinaryAttr).HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.BooleanAttr).HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.ByteAttr).HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); @@ -91,76 +91,83 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.SingleAttr).HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.StringAttr).HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.TimeAttr).HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Id1).IsRequired().HasField("_id1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever(); + modelBuilder.Entity().Property(t => t.Id1).HasField("_id1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever().IsRequired(); modelBuilder.Entity().Property("Timestamp").IsConcurrencyToken(); modelBuilder.Entity().OwnsOne(p => p.OwnedType).Property(p => p.SingleAttr); modelBuilder.Entity().ToTable("AllPropertyTypesRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().Property(t => t.BinaryAttr).IsRequired().HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.BooleanAttr).IsRequired().HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.ByteAttr).IsRequired().HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DateTimeAttr).IsRequired().HasField("_dateTimeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DateTimeOffsetAttr).IsRequired().HasField("_dateTimeOffsetAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DecimalAttr).IsRequired().HasField("_decimalAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DoubleAttr).IsRequired().HasField("_doubleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.GuidAttr).IsRequired().HasField("_guidAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int16Attr).IsRequired().HasField("_int16Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int32Attr).IsRequired().HasField("_int32Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int64Attr).IsRequired().HasField("_int64Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.SingleAttr).IsRequired().HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.StringAttr).IsRequired().HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.TimeAttr).IsRequired().HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().Property(t => t.BinaryAttr).HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.BooleanAttr).HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.ByteAttr).HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DateTimeAttr).HasField("_dateTimeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DateTimeOffsetAttr).HasField("_dateTimeOffsetAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DecimalAttr).HasField("_decimalAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DoubleAttr).HasField("_doubleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.GuidAttr).HasField("_guidAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int16Attr).HasField("_int16Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int32Attr).HasField("_int32Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int64Attr).HasField("_int64Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.SingleAttr).HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.StringAttr).HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.TimeAttr).HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().ToTable("BaseClassWithRequiredProperties").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().Property(t => t.Property0).IsRequired().HasField("_property0").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().Property(t => t.Property0).HasField("_property0").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().ToTable("BChilds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("BParentCollections").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithMany(p => p.BParentCollection).HasForeignKey("BChildRequiredId"); + modelBuilder.Entity().Navigation(e => e.BChildRequired).IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithMany(p => p.BParentCollection_2).HasForeignKey("BChildOptionalId"); modelBuilder.Entity().ToTable("BParentOptionals").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentOptional).HasForeignKey("BParentOptional", "BChildRequiredId"); + modelBuilder.Entity().Navigation(e => e.BChildRequired).IsRequired(); modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentOptional_1).HasForeignKey("BParentOptional_1Id"); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentOptional_2).HasForeignKey("BChild", "BParentOptional_2Id"); modelBuilder.Entity().ToTable("BParentRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentRequired).HasForeignKey("BChild", "BParentRequiredId").IsRequired(); - modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentRequired_1).HasForeignKey("BChild", "BParentRequired_1Id"); - modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentRequired_2).HasForeignKey("BParentRequired_2Id").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentRequired).HasForeignKey("BChild", "BParentRequiredId"); + modelBuilder.Entity().Navigation(e => e.BParentRequired).IsRequired(); + modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentRequired_1).HasForeignKey("BChild", "BParentRequired_1Id").IsRequired(); + modelBuilder.Entity().Navigation(e => e.BParentRequired_1).IsRequired(); + modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentRequired_2).HasForeignKey("BParentRequired_2Id"); + modelBuilder.Entity().Navigation(e => e.BParentRequired_2).IsRequired(); modelBuilder.Entity().ToTable("Children").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasMany(p => p.Children).WithOne(p => p.Parent).HasForeignKey("ParentId").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasMany(p => p.Children).WithOne(p => p.Parent).HasForeignKey("ParentId"); + modelBuilder.Entity().Navigation(e => e.Parent).IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Property1).IsRequired().HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("HiddenEntities").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("Masters").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasMany(p => p.Children).WithOne().HasForeignKey("Master_Children_Id").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasMany(p => p.Children).WithOne().HasForeignKey("MasterChildrenId"); + modelBuilder.Entity().Navigation(e => e.Children).HasField("_children").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Owned(); modelBuilder.Entity().ToTable("ParserTests").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.name1).HasField("_name1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.name2).HasField("_name2").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.name3).HasField("_name3").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); @@ -181,26 +188,36 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.name18).HasField("_name18").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("RenamedColumns").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasColumnName("Foo").HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasColumnName("Foo").HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("UChilds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("UParentCollections").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.UChildRequired).WithMany().HasForeignKey("UChildRequiredId"); + modelBuilder.Entity().Navigation(e => e.UChildRequired).IsRequired(); + modelBuilder.Entity().Navigation(e => e.UChildRequired).HasField("_uChildRequired").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().HasOne(p => p.UChildOptional).WithMany().HasForeignKey("UChildOptionalId"); + modelBuilder.Entity().Navigation(e => e.UChildOptional).HasField("_uChildOptional").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentOptional_UChildOptional_Id"); - modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentOptional_UChildCollection_Id"); + modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).HasDefaultValue("hello"); + modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentOptionalUChildOptionalId"); + modelBuilder.Entity().Navigation(e => e.UChildOptional).HasField("_uChildOptional").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentOptionalUChildCollectionId"); + modelBuilder.Entity().Navigation(e => e.UChildCollection).HasField("_uChildCollection").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UParentOptional", "UChildRequiredId"); + modelBuilder.Entity().Navigation(e => e.UChildRequired).IsRequired(); + modelBuilder.Entity().Navigation(e => e.UChildRequired).HasField("_uChildRequired").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("UParentRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UChild", "UParentRequired_UChildRequired_Id"); - modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentRequired_UChildCollection_Id").IsRequired(); - modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentRequired_UChildOptional_Id").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UChild", "UParentRequiredUChildRequiredId").IsRequired(); + modelBuilder.Entity().Navigation(e => e.UChildRequired).HasField("_uChildRequired").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentRequiredUChildCollectionId"); + modelBuilder.Entity().Navigation(e => e.UChildCollection).HasField("_uChildCollection").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentRequiredUChildOptionalId"); + modelBuilder.Entity().Navigation(e => e.UChildOptional).HasField("_uChildOptional").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); OnModelCreatedImpl(modelBuilder); } diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/AbstractBaseClass.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/AbstractBaseClass.generated.cs index f506f1cf1..8118b33b2 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/AbstractBaseClass.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/AbstractBaseClass.generated.cs @@ -39,7 +39,6 @@ protected AbstractBaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/AllPropertyTypesOptional.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/AllPropertyTypesOptional.generated.cs index a31e28272..4ed270044 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/AllPropertyTypesOptional.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/AllPropertyTypesOptional.generated.cs @@ -47,7 +47,6 @@ public AllPropertyTypesOptional(int id1) this.Id1 = id1; this.OwnedType = new global::Testing.OwnedType(); - Init(); } @@ -90,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -596,8 +595,19 @@ public int Id1 * Navigation properties *************************************************************************/ + /// + /// Backing field for OwnedType + /// protected global::Testing.OwnedType _ownedType; + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before setting. + /// partial void SetOwnedType(global::Testing.OwnedType oldValue, ref global::Testing.OwnedType newValue); + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before returning. + /// partial void GetOwnedType(ref global::Testing.OwnedType result); public virtual global::Testing.OwnedType OwnedType diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/AllPropertyTypesRequired.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/AllPropertyTypesRequired.generated.cs index 965a5474b..bf799d306 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/AllPropertyTypesRequired.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/AllPropertyTypesRequired.generated.cs @@ -86,7 +86,6 @@ public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteat this.TimeAttr = timeattr; - Init(); } @@ -142,7 +141,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BChild.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BChild.generated.cs index 802976967..85481da8f 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BChild.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BChild.generated.cs @@ -32,9 +32,6 @@ protected BChild() BParentCollection = new System.Collections.Generic.HashSet(); BParentCollection_2 = new System.Collections.Generic.HashSet(); - BParentRequired = new global::Testing.BParentRequired(); - BParentRequired_1 = new global::Testing.BParentRequired(); - BParentRequired_2 = new global::Testing.BParentRequired(); Init(); } @@ -59,13 +56,14 @@ public BChild(global::Testing.BParentRequired bparentrequired, global::Testing.B if (bparentrequired == null) throw new ArgumentNullException(nameof(bparentrequired)); this.BParentRequired = bparentrequired; + bparentrequired.BChildOptional = this; if (bparentrequired_2 == null) throw new ArgumentNullException(nameof(bparentrequired_2)); this.BParentRequired_2 = bparentrequired_2; + bparentrequired_2.BChildCollection.Add(this); this.BParentCollection = new System.Collections.Generic.HashSet(); this.BParentCollection_2 = new System.Collections.Generic.HashSet(); - Init(); } @@ -109,7 +107,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BParentCollection.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BParentCollection.generated.cs index af5faf66c..cc0cc710b 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BParentCollection.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BParentCollection.generated.cs @@ -27,8 +27,6 @@ public partial class BParentCollection /// protected BParentCollection() { - BChildRequired = global::Testing.BChild.CreateBChildUnsafe(); - Init(); } @@ -48,7 +46,7 @@ public BParentCollection(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; - + bchildrequired.BParentCollection.Add(this); Init(); } @@ -92,7 +90,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -107,8 +105,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -133,8 +142,19 @@ protected set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BParentOptional.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BParentOptional.generated.cs index 8c4093fa7..df70b0bd3 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BParentOptional.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BParentOptional.generated.cs @@ -28,7 +28,6 @@ public partial class BParentOptional protected BParentOptional() { BChildCollection = new System.Collections.Generic.HashSet(); - BChildRequired = global::Testing.BChild.CreateBChildUnsafe(); Init(); } @@ -49,9 +48,9 @@ public BParentOptional(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; + bchildrequired.BParentOptional = this; this.BChildCollection = new System.Collections.Generic.HashSet(); - Init(); } @@ -94,7 +93,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -109,8 +108,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -135,7 +145,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get @@ -148,8 +162,19 @@ private set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BParentRequired.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BParentRequired.generated.cs index e9d71bdd2..43edc21ed 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BParentRequired.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BParentRequired.generated.cs @@ -28,7 +28,6 @@ public partial class BParentRequired public BParentRequired() { BChildCollection = new System.Collections.Generic.HashSet(); - BChildRequired = global::Testing.BChild.CreateBChildUnsafe(); Init(); } @@ -63,7 +62,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -78,8 +77,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional @@ -101,8 +111,19 @@ protected set } } + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -127,7 +148,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BaseClass.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BaseClass.generated.cs index 1e11e199e..ab595e96c 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BaseClass.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BaseClass.generated.cs @@ -47,7 +47,6 @@ public BaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BaseClassWithRequiredProperties.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BaseClassWithRequiredProperties.generated.cs index bb337a79e..557698cc4 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BaseClassWithRequiredProperties.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/BaseClassWithRequiredProperties.generated.cs @@ -47,7 +47,6 @@ public BaseClassWithRequiredProperties(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } @@ -90,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/Child.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/Child.generated.cs index 355e18745..51e6460e1 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/Child.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/Child.generated.cs @@ -28,7 +28,6 @@ public partial class Child protected Child() { Children = new System.Collections.Generic.HashSet(); - Parent = global::Testing.Child.CreateChildUnsafe(); Init(); } @@ -50,12 +49,12 @@ public Child(global::Testing.Child parent, global::Testing.Master _master0) { if (parent == null) throw new ArgumentNullException(nameof(parent)); this.Parent = parent; + parent.Children.Add(this); if (_master0 == null) throw new ArgumentNullException(nameof(_master0)); _master0.Children.Add(this); this.Children = new System.Collections.Generic.HashSet(); - Init(); } @@ -99,7 +98,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -114,7 +113,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/ConcreteDerivedClass.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/ConcreteDerivedClass.generated.cs index cee4e6783..b05619dd1 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/ConcreteDerivedClass.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/ConcreteDerivedClass.generated.cs @@ -47,7 +47,6 @@ public ConcreteDerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs index b3fa04fdb..84cd0bc5c 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs @@ -51,7 +51,6 @@ public ConcreteDerivedClassWithRequiredProperties(string property1, string prope if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/DerivedClass.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/DerivedClass.generated.cs index 33e54b6e6..59dd6f39f 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/DerivedClass.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/DerivedClass.generated.cs @@ -47,7 +47,6 @@ public DerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/HiddenEntity.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/HiddenEntity.generated.cs index caa5dcc02..3ae611794 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/HiddenEntity.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/HiddenEntity.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/Master.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/Master.generated.cs index fd5ed86b8..61807d30b 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/Master.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/Master.generated.cs @@ -62,7 +62,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -77,7 +77,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/OwnedType.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/OwnedType.generated.cs index 356934d5a..66af3d729 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/OwnedType.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/OwnedType.generated.cs @@ -39,7 +39,6 @@ public OwnedType(global::Testing.AllPropertyTypesOptional _allpropertytypesoptio if (_allpropertytypesoptional0 == null) throw new ArgumentNullException(nameof(_allpropertytypesoptional0)); _allpropertytypesoptional0.OwnedType = this; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/ParserTest.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/ParserTest.generated.cs index 261469691..aa8ab86c0 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/ParserTest.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/ParserTest.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/RenamedColumn.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/RenamedColumn.generated.cs index e12f1a4c5..97af66423 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/RenamedColumn.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/RenamedColumn.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/UChild.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/UChild.generated.cs index bc67ba3d7..9b1d7572d 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/UChild.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/UChild.generated.cs @@ -57,7 +57,6 @@ public UChild(global::Testing.UParentRequired _uparentrequired1, global::Testing if (_uparentrequired2 == null) throw new ArgumentNullException(nameof(_uparentrequired2)); _uparentrequired2.UChildOptional = this; - Init(); } @@ -101,7 +100,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/UParentCollection.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/UParentCollection.generated.cs index b2fe3516b..c49ce677e 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/UParentCollection.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/UParentCollection.generated.cs @@ -27,8 +27,6 @@ public partial class UParentCollection /// protected UParentCollection() { - UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); - Init(); } @@ -49,7 +47,6 @@ public UParentCollection(global::Testing.UChild uchildrequired) if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); this.UChildRequired = uchildrequired; - Init(); } @@ -92,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -107,8 +104,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -133,8 +141,19 @@ protected set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/UParentOptional.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/UParentOptional.generated.cs index e27bf7bb8..4fbc70b55 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/UParentOptional.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/UParentOptional.generated.cs @@ -29,7 +29,6 @@ protected UParentOptional(): base() { PropertyInChild = "hello"; UChildCollection = new System.Collections.Generic.HashSet(); - UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); Init(); } @@ -53,7 +52,6 @@ public UParentOptional(global::Testing.UChild uchildrequired) this.UChildRequired = uchildrequired; this.UChildCollection = new System.Collections.Generic.HashSet(); - Init(); } @@ -109,8 +107,19 @@ public string PropertyInChild * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional @@ -132,7 +141,11 @@ public string PropertyInChild } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -145,8 +158,19 @@ private set } } + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// diff --git a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/UParentRequired.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/UParentRequired.generated.cs index be5063e5f..c3bde8ef8 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/UParentRequired.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore2/Generated/Entities/UParentRequired.generated.cs @@ -28,7 +28,6 @@ public partial class UParentRequired public UParentRequired() { UChildCollection = new System.Collections.Generic.HashSet(); - UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); Init(); } @@ -63,7 +62,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -78,8 +77,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -104,7 +114,11 @@ protected set } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -117,8 +131,19 @@ private set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/AllFeatureModel.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/AllFeatureModel.cs index 6153a7d78..47021ebc9 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/AllFeatureModel.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/AllFeatureModel.cs @@ -1 +1,1851 @@  +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class AllPropertyTypesRequired + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesRequired() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesRequired CreateAllPropertyTypesRequiredUnsafe() + { + return new AllPropertyTypesRequired(); + } + + /// + /// Public constructor with required data + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, string stringattr, TimeSpan timeattr) + { + this.BinaryAttr = binaryattr; + + this.BooleanAttr = booleanattr; + + this.ByteAttr = byteattr; + + this.DateTimeAttr = datetimeattr; + + this.DateTimeOffsetAttr = datetimeoffsetattr; + + this.DecimalAttr = decimalattr; + + this.DoubleAttr = doubleattr; + + this.GuidAttr = guidattr; + + this.Int16Attr = int16attr; + + this.Int32Attr = int32attr; + + this.Int64Attr = int64attr; + + this.SingleAttr = singleattr; + + if (string.IsNullOrEmpty(stringattr)) throw new ArgumentNullException(nameof(stringattr)); + this.StringAttr = stringattr; + + this.TimeAttr = timeattr; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static AllPropertyTypesRequired Create(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, string stringattr, TimeSpan timeattr) + { + return new AllPropertyTypesRequired(binaryattr, booleanattr, byteattr, datetimeattr, datetimeoffsetattr, decimalattr, doubleattr, guidattr, int16attr, int32attr, int64attr, singleattr, stringattr, timeattr); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + /// + /// Required + /// + [Required] + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool oldValue, ref bool newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool result); + + /// + /// Required + /// + [Required] + public bool BooleanAttr + { + get + { + bool value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte oldValue, ref byte newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte result); + + /// + /// Required + /// + [Required] + public byte ByteAttr + { + get + { + byte value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime oldValue, ref DateTime newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime result); + + /// + /// Required + /// + [Required] + public DateTime DateTimeAttr + { + get + { + DateTime value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset oldValue, ref DateTimeOffset newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset result); + + /// + /// Required + /// + [Required] + public DateTimeOffset DateTimeOffsetAttr + { + get + { + DateTimeOffset value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal oldValue, ref decimal newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal result); + + /// + /// Required + /// + [Required] + public decimal DecimalAttr + { + get + { + decimal value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double oldValue, ref double newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double result); + + /// + /// Required + /// + [Required] + public double DoubleAttr + { + get + { + double value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid oldValue, ref Guid newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid result); + + /// + /// Required + /// + [Required] + public Guid GuidAttr + { + get + { + Guid value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short oldValue, ref short newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short result); + + /// + /// Required + /// + [Required] + public short Int16Attr + { + get + { + short value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int result); + + /// + /// Required + /// + [Required] + public int Int32Attr + { + get + { + int value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long oldValue, ref long newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long result); + + /// + /// Required + /// + [Required] + public long Int64Attr + { + get + { + long value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single oldValue, ref Single newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single result); + + /// + /// Required + /// + [Required] + public Single SingleAttr + { + get + { + Single value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + /// + /// Required + /// + [Required] + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan oldValue, ref TimeSpan newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan result); + + /// + /// Required + /// + [Required] + public TimeSpan TimeAttr + { + get + { + TimeSpan value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class AllPropertyTypesOptional + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesOptional() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesOptional CreateAllPropertyTypesOptionalUnsafe() + { + return new AllPropertyTypesOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public AllPropertyTypesOptional(int id1) + { + this.Id1 = id1; + + this.OwnedType = new global::Testing.OwnedType(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static AllPropertyTypesOptional Create(int id1) + { + return new AllPropertyTypesOptional(id1); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool? _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool? oldValue, ref bool? newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool? result); + + public bool? BooleanAttr + { + get + { + bool? value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool? oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte? _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte? oldValue, ref byte? newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte? result); + + public byte? ByteAttr + { + get + { + byte? value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte? oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime? _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime? oldValue, ref DateTime? newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime? result); + + public DateTime? DateTimeAttr + { + get + { + DateTime? value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime? oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset? _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset? oldValue, ref DateTimeOffset? newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset? result); + + public DateTimeOffset? DateTimeOffsetAttr + { + get + { + DateTimeOffset? value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset? oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal? _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal? oldValue, ref decimal? newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal? result); + + public decimal? DecimalAttr + { + get + { + decimal? value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal? oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double? _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double? oldValue, ref double? newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double? result); + + public double? DoubleAttr + { + get + { + double? value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double? oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid? _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid? oldValue, ref Guid? newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid? result); + + public Guid? GuidAttr + { + get + { + Guid? value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid? oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short? _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short? oldValue, ref short? newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short? result); + + public short? Int16Attr + { + get + { + short? value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short? oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int? _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int? oldValue, ref int? newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int? result); + + public int? Int32Attr + { + get + { + int? value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int? oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long? _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long? oldValue, ref long? newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long? result); + + public long? Int64Attr + { + get + { + long? value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long? oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single? _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single? oldValue, ref Single? newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single? result); + + public Single? SingleAttr + { + get + { + Single? value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single? oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan? _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan? oldValue, ref TimeSpan? newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan? result); + + public TimeSpan? TimeAttr + { + get + { + TimeSpan? value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan? oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + /// + /// Backing field for Id1 + /// + internal int _id1; + /// + /// When provided in a partial class, allows value of Id1 to be changed before setting. + /// + partial void SetId1(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id1 to be changed before returning. + /// + partial void GetId1(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id1 + { + get + { + int value = _id1; + GetId1(ref value); + return (_id1 = value); + } + set + { + int oldValue = _id1; + SetId1(oldValue, ref value); + if (oldValue != value) + { + _id1 = value; + } + } + } + + /// + /// Concurrency token + /// + [Timestamp] + public Byte[] Timestamp { get; set; } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for OwnedType + /// + protected global::Testing.OwnedType _ownedType; + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before setting. + /// + partial void SetOwnedType(global::Testing.OwnedType oldValue, ref global::Testing.OwnedType newValue); + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before returning. + /// + partial void GetOwnedType(ref global::Testing.OwnedType result); + + public virtual global::Testing.OwnedType OwnedType + { + get + { + global::Testing.OwnedType value = _ownedType; + GetOwnedType(ref value); + return (_ownedType = value); + } + set + { + global::Testing.OwnedType oldValue = _ownedType; + SetOwnedType(oldValue, ref value); + if (oldValue != value) + { + _ownedType = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentRequired + { + partial void Init(); + + /// + /// Default constructor + /// + public UParentRequired() + { + UChildCollection = new System.Collections.Generic.HashSet(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentOptional: global::Testing.HiddenEntity + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentOptional(): base() + { + PropertyInChild = "hello"; + UChildCollection = new System.Collections.Generic.HashSet(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentOptional CreateUParentOptionalUnsafe() + { + return new UParentOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentOptional(global::Testing.UChild uchildrequired) + { + this.PropertyInChild = "hello"; + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + this.UChildCollection = new System.Collections.Generic.HashSet(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentOptional Create(global::Testing.UChild uchildrequired) + { + return new UParentOptional(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for PropertyInChild + /// + protected string _propertyInChild; + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before setting. + /// + partial void SetPropertyInChild(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before returning. + /// + partial void GetPropertyInChild(ref string result); + + /// + /// Default value = "hello" + /// + public string PropertyInChild + { + get + { + string value = _propertyInChild; + GetPropertyInChild(ref value); + return (_propertyInChild = value); + } + set + { + string oldValue = _propertyInChild; + SetPropertyInChild(oldValue, ref value); + if (oldValue != value) + { + _propertyInChild = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentCollection + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentCollection() + { + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentCollection CreateUParentCollectionUnsafe() + { + return new UParentCollection(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentCollection(global::Testing.UChild uchildrequired) + { + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentCollection Create(global::Testing.UChild uchildrequired) + { + return new UParentCollection(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UChild + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UChild() + { + // NOTE: This class has one-to-one associations with UChild. + // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other. + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UChild CreateUChildUnsafe() + { + return new UChild(); + } + + /// + /// Public constructor with required data + /// diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Context/AllFeatureModel.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Context/AllFeatureModel.generated.cs index 8b4ef3701..5299ec2a6 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Context/AllFeatureModel.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Context/AllFeatureModel.generated.cs @@ -76,7 +76,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().ToTable("AllPropertyTypesOptionals").HasKey(t => new { t.Id, t.Id1 }); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.BinaryAttr).HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.BooleanAttr).HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.ByteAttr).HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); @@ -91,76 +91,83 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.SingleAttr).HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.StringAttr).HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.TimeAttr).HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Id1).IsRequired().HasField("_id1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever(); + modelBuilder.Entity().Property(t => t.Id1).HasField("_id1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever().IsRequired(); modelBuilder.Entity().Property("Timestamp").IsConcurrencyToken(); modelBuilder.Entity().OwnsOne(p => p.OwnedType).Property(p => p.SingleAttr); modelBuilder.Entity().ToTable("AllPropertyTypesRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().Property(t => t.BinaryAttr).IsRequired().HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.BooleanAttr).IsRequired().HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.ByteAttr).IsRequired().HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DateTimeAttr).IsRequired().HasField("_dateTimeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DateTimeOffsetAttr).IsRequired().HasField("_dateTimeOffsetAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DecimalAttr).IsRequired().HasField("_decimalAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DoubleAttr).IsRequired().HasField("_doubleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.GuidAttr).IsRequired().HasField("_guidAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int16Attr).IsRequired().HasField("_int16Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int32Attr).IsRequired().HasField("_int32Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int64Attr).IsRequired().HasField("_int64Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.SingleAttr).IsRequired().HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.StringAttr).IsRequired().HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.TimeAttr).IsRequired().HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().Property(t => t.BinaryAttr).HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.BooleanAttr).HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.ByteAttr).HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DateTimeAttr).HasField("_dateTimeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DateTimeOffsetAttr).HasField("_dateTimeOffsetAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DecimalAttr).HasField("_decimalAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DoubleAttr).HasField("_doubleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.GuidAttr).HasField("_guidAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int16Attr).HasField("_int16Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int32Attr).HasField("_int32Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int64Attr).HasField("_int64Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.SingleAttr).HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.StringAttr).HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.TimeAttr).HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().ToTable("BaseClassWithRequiredProperties").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().Property(t => t.Property0).IsRequired().HasField("_property0").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().Property(t => t.Property0).HasField("_property0").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().ToTable("BChilds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("BParentCollections").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithMany(p => p.BParentCollection).HasForeignKey("BChildRequiredId"); + modelBuilder.Entity().Navigation(e => e.BChildRequired).IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithMany(p => p.BParentCollection_2).HasForeignKey("BChildOptionalId"); modelBuilder.Entity().ToTable("BParentOptionals").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentOptional).HasForeignKey("BParentOptional", "BChildRequiredId"); + modelBuilder.Entity().Navigation(e => e.BChildRequired).IsRequired(); modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentOptional_1).HasForeignKey("BParentOptional_1Id"); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentOptional_2).HasForeignKey("BChild", "BParentOptional_2Id"); modelBuilder.Entity().ToTable("BParentRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentRequired).HasForeignKey("BChild", "BParentRequiredId").IsRequired(); - modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentRequired_1).HasForeignKey("BChild", "BParentRequired_1Id"); - modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentRequired_2).HasForeignKey("BParentRequired_2Id").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentRequired).HasForeignKey("BChild", "BParentRequiredId"); + modelBuilder.Entity().Navigation(e => e.BParentRequired).IsRequired(); + modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentRequired_1).HasForeignKey("BChild", "BParentRequired_1Id").IsRequired(); + modelBuilder.Entity().Navigation(e => e.BParentRequired_1).IsRequired(); + modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentRequired_2).HasForeignKey("BParentRequired_2Id"); + modelBuilder.Entity().Navigation(e => e.BParentRequired_2).IsRequired(); modelBuilder.Entity().ToTable("Children").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasMany(p => p.Children).WithOne(p => p.Parent).HasForeignKey("ParentId").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasMany(p => p.Children).WithOne(p => p.Parent).HasForeignKey("ParentId"); + modelBuilder.Entity().Navigation(e => e.Parent).IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Property1).IsRequired().HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("HiddenEntities").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("Masters").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasMany(p => p.Children).WithOne().HasForeignKey("Master_Children_Id").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasMany(p => p.Children).WithOne().HasForeignKey("MasterChildrenId"); + modelBuilder.Entity().Navigation(e => e.Children).HasField("_children").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Owned(); modelBuilder.Entity().ToTable("ParserTests").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.name1).HasField("_name1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.name2).HasField("_name2").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.name3).HasField("_name3").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); @@ -181,26 +188,36 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.name18).HasField("_name18").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("RenamedColumns").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasColumnName("Foo").HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasColumnName("Foo").HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("UChilds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("UParentCollections").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.UChildRequired).WithMany().HasForeignKey("UChildRequiredId"); + modelBuilder.Entity().Navigation(e => e.UChildRequired).IsRequired(); + modelBuilder.Entity().Navigation(e => e.UChildRequired).HasField("_uChildRequired").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().HasOne(p => p.UChildOptional).WithMany().HasForeignKey("UChildOptionalId"); + modelBuilder.Entity().Navigation(e => e.UChildOptional).HasField("_uChildOptional").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentOptional_UChildOptional_Id"); - modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentOptional_UChildCollection_Id"); + modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).HasDefaultValue("hello"); + modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentOptionalUChildOptionalId"); + modelBuilder.Entity().Navigation(e => e.UChildOptional).HasField("_uChildOptional").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentOptionalUChildCollectionId"); + modelBuilder.Entity().Navigation(e => e.UChildCollection).HasField("_uChildCollection").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UParentOptional", "UChildRequiredId"); + modelBuilder.Entity().Navigation(e => e.UChildRequired).IsRequired(); + modelBuilder.Entity().Navigation(e => e.UChildRequired).HasField("_uChildRequired").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("UParentRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UChild", "UParentRequired_UChildRequired_Id"); - modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentRequired_UChildCollection_Id").IsRequired(); - modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentRequired_UChildOptional_Id").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UChild", "UParentRequiredUChildRequiredId").IsRequired(); + modelBuilder.Entity().Navigation(e => e.UChildRequired).HasField("_uChildRequired").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentRequiredUChildCollectionId"); + modelBuilder.Entity().Navigation(e => e.UChildCollection).HasField("_uChildCollection").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentRequiredUChildOptionalId"); + modelBuilder.Entity().Navigation(e => e.UChildOptional).HasField("_uChildOptional").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); OnModelCreatedImpl(modelBuilder); } diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/AbstractBaseClass.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/AbstractBaseClass.generated.cs index f506f1cf1..8118b33b2 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/AbstractBaseClass.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/AbstractBaseClass.generated.cs @@ -39,7 +39,6 @@ protected AbstractBaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/AllPropertyTypesOptional.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/AllPropertyTypesOptional.generated.cs index a31e28272..4ed270044 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/AllPropertyTypesOptional.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/AllPropertyTypesOptional.generated.cs @@ -47,7 +47,6 @@ public AllPropertyTypesOptional(int id1) this.Id1 = id1; this.OwnedType = new global::Testing.OwnedType(); - Init(); } @@ -90,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -596,8 +595,19 @@ public int Id1 * Navigation properties *************************************************************************/ + /// + /// Backing field for OwnedType + /// protected global::Testing.OwnedType _ownedType; + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before setting. + /// partial void SetOwnedType(global::Testing.OwnedType oldValue, ref global::Testing.OwnedType newValue); + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before returning. + /// partial void GetOwnedType(ref global::Testing.OwnedType result); public virtual global::Testing.OwnedType OwnedType diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/AllPropertyTypesRequired.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/AllPropertyTypesRequired.generated.cs index 965a5474b..bf799d306 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/AllPropertyTypesRequired.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/AllPropertyTypesRequired.generated.cs @@ -86,7 +86,6 @@ public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteat this.TimeAttr = timeattr; - Init(); } @@ -142,7 +141,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BChild.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BChild.generated.cs index 802976967..85481da8f 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BChild.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BChild.generated.cs @@ -32,9 +32,6 @@ protected BChild() BParentCollection = new System.Collections.Generic.HashSet(); BParentCollection_2 = new System.Collections.Generic.HashSet(); - BParentRequired = new global::Testing.BParentRequired(); - BParentRequired_1 = new global::Testing.BParentRequired(); - BParentRequired_2 = new global::Testing.BParentRequired(); Init(); } @@ -59,13 +56,14 @@ public BChild(global::Testing.BParentRequired bparentrequired, global::Testing.B if (bparentrequired == null) throw new ArgumentNullException(nameof(bparentrequired)); this.BParentRequired = bparentrequired; + bparentrequired.BChildOptional = this; if (bparentrequired_2 == null) throw new ArgumentNullException(nameof(bparentrequired_2)); this.BParentRequired_2 = bparentrequired_2; + bparentrequired_2.BChildCollection.Add(this); this.BParentCollection = new System.Collections.Generic.HashSet(); this.BParentCollection_2 = new System.Collections.Generic.HashSet(); - Init(); } @@ -109,7 +107,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BParentCollection.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BParentCollection.generated.cs index af5faf66c..cc0cc710b 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BParentCollection.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BParentCollection.generated.cs @@ -27,8 +27,6 @@ public partial class BParentCollection /// protected BParentCollection() { - BChildRequired = global::Testing.BChild.CreateBChildUnsafe(); - Init(); } @@ -48,7 +46,7 @@ public BParentCollection(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; - + bchildrequired.BParentCollection.Add(this); Init(); } @@ -92,7 +90,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -107,8 +105,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -133,8 +142,19 @@ protected set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BParentOptional.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BParentOptional.generated.cs index 8c4093fa7..df70b0bd3 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BParentOptional.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BParentOptional.generated.cs @@ -28,7 +28,6 @@ public partial class BParentOptional protected BParentOptional() { BChildCollection = new System.Collections.Generic.HashSet(); - BChildRequired = global::Testing.BChild.CreateBChildUnsafe(); Init(); } @@ -49,9 +48,9 @@ public BParentOptional(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; + bchildrequired.BParentOptional = this; this.BChildCollection = new System.Collections.Generic.HashSet(); - Init(); } @@ -94,7 +93,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -109,8 +108,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -135,7 +145,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get @@ -148,8 +162,19 @@ private set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BParentRequired.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BParentRequired.generated.cs index e9d71bdd2..43edc21ed 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BParentRequired.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BParentRequired.generated.cs @@ -28,7 +28,6 @@ public partial class BParentRequired public BParentRequired() { BChildCollection = new System.Collections.Generic.HashSet(); - BChildRequired = global::Testing.BChild.CreateBChildUnsafe(); Init(); } @@ -63,7 +62,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -78,8 +77,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional @@ -101,8 +111,19 @@ protected set } } + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -127,7 +148,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BaseClass.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BaseClass.generated.cs index 1e11e199e..ab595e96c 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BaseClass.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BaseClass.generated.cs @@ -47,7 +47,6 @@ public BaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BaseClassWithRequiredProperties.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BaseClassWithRequiredProperties.generated.cs index bb337a79e..557698cc4 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BaseClassWithRequiredProperties.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/BaseClassWithRequiredProperties.generated.cs @@ -47,7 +47,6 @@ public BaseClassWithRequiredProperties(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } @@ -90,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/Child.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/Child.generated.cs index 355e18745..51e6460e1 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/Child.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/Child.generated.cs @@ -28,7 +28,6 @@ public partial class Child protected Child() { Children = new System.Collections.Generic.HashSet(); - Parent = global::Testing.Child.CreateChildUnsafe(); Init(); } @@ -50,12 +49,12 @@ public Child(global::Testing.Child parent, global::Testing.Master _master0) { if (parent == null) throw new ArgumentNullException(nameof(parent)); this.Parent = parent; + parent.Children.Add(this); if (_master0 == null) throw new ArgumentNullException(nameof(_master0)); _master0.Children.Add(this); this.Children = new System.Collections.Generic.HashSet(); - Init(); } @@ -99,7 +98,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -114,7 +113,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/ConcreteDerivedClass.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/ConcreteDerivedClass.generated.cs index cee4e6783..b05619dd1 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/ConcreteDerivedClass.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/ConcreteDerivedClass.generated.cs @@ -47,7 +47,6 @@ public ConcreteDerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs index b3fa04fdb..84cd0bc5c 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs @@ -51,7 +51,6 @@ public ConcreteDerivedClassWithRequiredProperties(string property1, string prope if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/DerivedClass.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/DerivedClass.generated.cs index 33e54b6e6..59dd6f39f 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/DerivedClass.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/DerivedClass.generated.cs @@ -47,7 +47,6 @@ public DerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/HiddenEntity.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/HiddenEntity.generated.cs index caa5dcc02..3ae611794 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/HiddenEntity.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/HiddenEntity.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/Master.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/Master.generated.cs index fd5ed86b8..61807d30b 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/Master.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/Master.generated.cs @@ -62,7 +62,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -77,7 +77,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/OwnedType.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/OwnedType.generated.cs index 356934d5a..66af3d729 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/OwnedType.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/OwnedType.generated.cs @@ -39,7 +39,6 @@ public OwnedType(global::Testing.AllPropertyTypesOptional _allpropertytypesoptio if (_allpropertytypesoptional0 == null) throw new ArgumentNullException(nameof(_allpropertytypesoptional0)); _allpropertytypesoptional0.OwnedType = this; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/ParserTest.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/ParserTest.generated.cs index 261469691..aa8ab86c0 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/ParserTest.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/ParserTest.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/RenamedColumn.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/RenamedColumn.generated.cs index e12f1a4c5..97af66423 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/RenamedColumn.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/RenamedColumn.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/UChild.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/UChild.generated.cs index bc67ba3d7..9b1d7572d 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/UChild.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/UChild.generated.cs @@ -57,7 +57,6 @@ public UChild(global::Testing.UParentRequired _uparentrequired1, global::Testing if (_uparentrequired2 == null) throw new ArgumentNullException(nameof(_uparentrequired2)); _uparentrequired2.UChildOptional = this; - Init(); } @@ -101,7 +100,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/UParentCollection.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/UParentCollection.generated.cs index b2fe3516b..c49ce677e 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/UParentCollection.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/UParentCollection.generated.cs @@ -27,8 +27,6 @@ public partial class UParentCollection /// protected UParentCollection() { - UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); - Init(); } @@ -49,7 +47,6 @@ public UParentCollection(global::Testing.UChild uchildrequired) if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); this.UChildRequired = uchildrequired; - Init(); } @@ -92,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -107,8 +104,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -133,8 +141,19 @@ protected set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/UParentOptional.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/UParentOptional.generated.cs index e27bf7bb8..4fbc70b55 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/UParentOptional.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/UParentOptional.generated.cs @@ -29,7 +29,6 @@ protected UParentOptional(): base() { PropertyInChild = "hello"; UChildCollection = new System.Collections.Generic.HashSet(); - UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); Init(); } @@ -53,7 +52,6 @@ public UParentOptional(global::Testing.UChild uchildrequired) this.UChildRequired = uchildrequired; this.UChildCollection = new System.Collections.Generic.HashSet(); - Init(); } @@ -109,8 +107,19 @@ public string PropertyInChild * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional @@ -132,7 +141,11 @@ public string PropertyInChild } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -145,8 +158,19 @@ private set } } + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// diff --git a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/UParentRequired.generated.cs b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/UParentRequired.generated.cs index be5063e5f..c3bde8ef8 100644 --- a/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/UParentRequired.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetCore3/Generated/Entities/UParentRequired.generated.cs @@ -28,7 +28,6 @@ public partial class UParentRequired public UParentRequired() { UChildCollection = new System.Collections.Generic.HashSet(); - UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); Init(); } @@ -63,7 +62,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -78,8 +77,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -104,7 +114,11 @@ protected set } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -117,8 +131,19 @@ private set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/AllFeatureModel.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/AllFeatureModel.cs index 6153a7d78..47021ebc9 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/AllFeatureModel.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/AllFeatureModel.cs @@ -1 +1,1851 @@  +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class AllPropertyTypesRequired + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesRequired() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesRequired CreateAllPropertyTypesRequiredUnsafe() + { + return new AllPropertyTypesRequired(); + } + + /// + /// Public constructor with required data + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, string stringattr, TimeSpan timeattr) + { + this.BinaryAttr = binaryattr; + + this.BooleanAttr = booleanattr; + + this.ByteAttr = byteattr; + + this.DateTimeAttr = datetimeattr; + + this.DateTimeOffsetAttr = datetimeoffsetattr; + + this.DecimalAttr = decimalattr; + + this.DoubleAttr = doubleattr; + + this.GuidAttr = guidattr; + + this.Int16Attr = int16attr; + + this.Int32Attr = int32attr; + + this.Int64Attr = int64attr; + + this.SingleAttr = singleattr; + + if (string.IsNullOrEmpty(stringattr)) throw new ArgumentNullException(nameof(stringattr)); + this.StringAttr = stringattr; + + this.TimeAttr = timeattr; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static AllPropertyTypesRequired Create(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, string stringattr, TimeSpan timeattr) + { + return new AllPropertyTypesRequired(binaryattr, booleanattr, byteattr, datetimeattr, datetimeoffsetattr, decimalattr, doubleattr, guidattr, int16attr, int32attr, int64attr, singleattr, stringattr, timeattr); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + /// + /// Required + /// + [Required] + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool oldValue, ref bool newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool result); + + /// + /// Required + /// + [Required] + public bool BooleanAttr + { + get + { + bool value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte oldValue, ref byte newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte result); + + /// + /// Required + /// + [Required] + public byte ByteAttr + { + get + { + byte value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime oldValue, ref DateTime newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime result); + + /// + /// Required + /// + [Required] + public DateTime DateTimeAttr + { + get + { + DateTime value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset oldValue, ref DateTimeOffset newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset result); + + /// + /// Required + /// + [Required] + public DateTimeOffset DateTimeOffsetAttr + { + get + { + DateTimeOffset value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal oldValue, ref decimal newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal result); + + /// + /// Required + /// + [Required] + public decimal DecimalAttr + { + get + { + decimal value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double oldValue, ref double newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double result); + + /// + /// Required + /// + [Required] + public double DoubleAttr + { + get + { + double value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid oldValue, ref Guid newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid result); + + /// + /// Required + /// + [Required] + public Guid GuidAttr + { + get + { + Guid value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short oldValue, ref short newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short result); + + /// + /// Required + /// + [Required] + public short Int16Attr + { + get + { + short value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int result); + + /// + /// Required + /// + [Required] + public int Int32Attr + { + get + { + int value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long oldValue, ref long newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long result); + + /// + /// Required + /// + [Required] + public long Int64Attr + { + get + { + long value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single oldValue, ref Single newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single result); + + /// + /// Required + /// + [Required] + public Single SingleAttr + { + get + { + Single value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + /// + /// Required + /// + [Required] + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan oldValue, ref TimeSpan newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan result); + + /// + /// Required + /// + [Required] + public TimeSpan TimeAttr + { + get + { + TimeSpan value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class AllPropertyTypesOptional + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesOptional() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesOptional CreateAllPropertyTypesOptionalUnsafe() + { + return new AllPropertyTypesOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public AllPropertyTypesOptional(int id1) + { + this.Id1 = id1; + + this.OwnedType = new global::Testing.OwnedType(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static AllPropertyTypesOptional Create(int id1) + { + return new AllPropertyTypesOptional(id1); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool? _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool? oldValue, ref bool? newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool? result); + + public bool? BooleanAttr + { + get + { + bool? value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool? oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte? _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte? oldValue, ref byte? newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte? result); + + public byte? ByteAttr + { + get + { + byte? value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte? oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime? _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime? oldValue, ref DateTime? newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime? result); + + public DateTime? DateTimeAttr + { + get + { + DateTime? value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime? oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset? _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset? oldValue, ref DateTimeOffset? newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset? result); + + public DateTimeOffset? DateTimeOffsetAttr + { + get + { + DateTimeOffset? value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset? oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal? _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal? oldValue, ref decimal? newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal? result); + + public decimal? DecimalAttr + { + get + { + decimal? value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal? oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double? _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double? oldValue, ref double? newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double? result); + + public double? DoubleAttr + { + get + { + double? value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double? oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid? _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid? oldValue, ref Guid? newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid? result); + + public Guid? GuidAttr + { + get + { + Guid? value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid? oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short? _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short? oldValue, ref short? newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short? result); + + public short? Int16Attr + { + get + { + short? value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short? oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int? _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int? oldValue, ref int? newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int? result); + + public int? Int32Attr + { + get + { + int? value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int? oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long? _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long? oldValue, ref long? newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long? result); + + public long? Int64Attr + { + get + { + long? value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long? oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single? _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single? oldValue, ref Single? newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single? result); + + public Single? SingleAttr + { + get + { + Single? value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single? oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan? _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan? oldValue, ref TimeSpan? newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan? result); + + public TimeSpan? TimeAttr + { + get + { + TimeSpan? value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan? oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + /// + /// Backing field for Id1 + /// + internal int _id1; + /// + /// When provided in a partial class, allows value of Id1 to be changed before setting. + /// + partial void SetId1(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id1 to be changed before returning. + /// + partial void GetId1(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id1 + { + get + { + int value = _id1; + GetId1(ref value); + return (_id1 = value); + } + set + { + int oldValue = _id1; + SetId1(oldValue, ref value); + if (oldValue != value) + { + _id1 = value; + } + } + } + + /// + /// Concurrency token + /// + [Timestamp] + public Byte[] Timestamp { get; set; } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for OwnedType + /// + protected global::Testing.OwnedType _ownedType; + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before setting. + /// + partial void SetOwnedType(global::Testing.OwnedType oldValue, ref global::Testing.OwnedType newValue); + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before returning. + /// + partial void GetOwnedType(ref global::Testing.OwnedType result); + + public virtual global::Testing.OwnedType OwnedType + { + get + { + global::Testing.OwnedType value = _ownedType; + GetOwnedType(ref value); + return (_ownedType = value); + } + set + { + global::Testing.OwnedType oldValue = _ownedType; + SetOwnedType(oldValue, ref value); + if (oldValue != value) + { + _ownedType = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentRequired + { + partial void Init(); + + /// + /// Default constructor + /// + public UParentRequired() + { + UChildCollection = new System.Collections.Generic.HashSet(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentOptional: global::Testing.HiddenEntity + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentOptional(): base() + { + PropertyInChild = "hello"; + UChildCollection = new System.Collections.Generic.HashSet(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentOptional CreateUParentOptionalUnsafe() + { + return new UParentOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentOptional(global::Testing.UChild uchildrequired) + { + this.PropertyInChild = "hello"; + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + this.UChildCollection = new System.Collections.Generic.HashSet(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentOptional Create(global::Testing.UChild uchildrequired) + { + return new UParentOptional(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for PropertyInChild + /// + protected string _propertyInChild; + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before setting. + /// + partial void SetPropertyInChild(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before returning. + /// + partial void GetPropertyInChild(ref string result); + + /// + /// Default value = "hello" + /// + public string PropertyInChild + { + get + { + string value = _propertyInChild; + GetPropertyInChild(ref value); + return (_propertyInChild = value); + } + set + { + string oldValue = _propertyInChild; + SetPropertyInChild(oldValue, ref value); + if (oldValue != value) + { + _propertyInChild = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentCollection + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentCollection() + { + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentCollection CreateUParentCollectionUnsafe() + { + return new UParentCollection(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentCollection(global::Testing.UChild uchildrequired) + { + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentCollection Create(global::Testing.UChild uchildrequired) + { + return new UParentCollection(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UChild + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UChild() + { + // NOTE: This class has one-to-one associations with UChild. + // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other. + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UChild CreateUChildUnsafe() + { + return new UChild(); + } + + /// + /// Public constructor with required data + /// diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Context/AllFeatureModel.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Context/AllFeatureModel.generated.cs index a7b1a41f8..96e25ec93 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Context/AllFeatureModel.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Context/AllFeatureModel.generated.cs @@ -76,7 +76,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().ToTable("AllPropertyTypesOptionals").HasKey(t => new { t.Id, t.Id1 }); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.BinaryAttr).HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.BooleanAttr).HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.ByteAttr).HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); @@ -91,76 +91,83 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.SingleAttr).HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.StringAttr).HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.TimeAttr).HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Id1).IsRequired().HasField("_id1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever(); + modelBuilder.Entity().Property(t => t.Id1).HasField("_id1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever().IsRequired(); modelBuilder.Entity().Property("Timestamp").IsConcurrencyToken(); modelBuilder.Entity().OwnsOne(p => p.OwnedType).Property(p => p.SingleAttr); modelBuilder.Entity().ToTable("AllPropertyTypesRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().Property(t => t.BinaryAttr).IsRequired().HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.BooleanAttr).IsRequired().HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.ByteAttr).IsRequired().HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DateTimeAttr).IsRequired().HasField("_dateTimeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DateTimeOffsetAttr).IsRequired().HasField("_dateTimeOffsetAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DecimalAttr).IsRequired().HasField("_decimalAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DoubleAttr).IsRequired().HasField("_doubleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.GuidAttr).IsRequired().HasField("_guidAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int16Attr).IsRequired().HasField("_int16Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int32Attr).IsRequired().HasField("_int32Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int64Attr).IsRequired().HasField("_int64Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.SingleAttr).IsRequired().HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.StringAttr).IsRequired().HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.TimeAttr).IsRequired().HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().Property(t => t.BinaryAttr).HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.BooleanAttr).HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.ByteAttr).HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DateTimeAttr).HasField("_dateTimeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DateTimeOffsetAttr).HasField("_dateTimeOffsetAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DecimalAttr).HasField("_decimalAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DoubleAttr).HasField("_doubleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.GuidAttr).HasField("_guidAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int16Attr).HasField("_int16Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int32Attr).HasField("_int32Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int64Attr).HasField("_int64Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.SingleAttr).HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.StringAttr).HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.TimeAttr).HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().ToTable("BaseClassWithRequiredProperties").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().Property(t => t.Property0).IsRequired().HasField("_property0").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().Property(t => t.Property0).HasField("_property0").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().ToTable("BChilds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("BParentCollections").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithMany(p => p.BParentCollection).HasForeignKey("BChildRequiredId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.BChildRequired).IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithMany(p => p.BParentCollection_2).HasForeignKey("BChildOptionalId").OnDelete(DeleteBehavior.NoAction); modelBuilder.Entity().ToTable("BParentOptionals").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentOptional).HasForeignKey("BParentOptional", "BChildRequiredId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.BChildRequired).IsRequired(); modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentOptional_1).HasForeignKey("BParentOptional_1Id").OnDelete(DeleteBehavior.NoAction); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentOptional_2).HasForeignKey("BChild", "BParentOptional_2Id").OnDelete(DeleteBehavior.NoAction); modelBuilder.Entity().ToTable("BParentRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentRequired).HasForeignKey("BChild", "BParentRequiredId").OnDelete(DeleteBehavior.NoAction).IsRequired(); - modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentRequired_1).HasForeignKey("BChild", "BParentRequired_1Id").OnDelete(DeleteBehavior.NoAction); - modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentRequired_2).HasForeignKey("BParentRequired_2Id").OnDelete(DeleteBehavior.NoAction).IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentRequired).HasForeignKey("BChild", "BParentRequiredId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.BParentRequired).IsRequired(); + modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentRequired_1).HasForeignKey("BChild", "BParentRequired_1Id").OnDelete(DeleteBehavior.NoAction).IsRequired(); + modelBuilder.Entity().Navigation(e => e.BParentRequired_1).IsRequired(); + modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentRequired_2).HasForeignKey("BParentRequired_2Id").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.BParentRequired_2).IsRequired(); modelBuilder.Entity().ToTable("Children").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasMany(p => p.Children).WithOne(p => p.Parent).HasForeignKey("ParentId").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasMany(p => p.Children).WithOne(p => p.Parent).HasForeignKey("ParentId"); + modelBuilder.Entity().Navigation(e => e.Parent).IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Property1).IsRequired().HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("HiddenEntities").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("Masters").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasMany(p => p.Children).WithOne().HasForeignKey("Master_Children_Id").OnDelete(DeleteBehavior.NoAction).IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasMany(p => p.Children).WithOne().HasForeignKey("MasterChildrenId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.Children).HasField("_children").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Owned(); modelBuilder.Entity().ToTable("ParserTests").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.name1).HasField("_name1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.name2).HasField("_name2").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.name3).HasField("_name3").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); @@ -181,26 +188,36 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.name18).HasField("_name18").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("RenamedColumns").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasColumnName("Foo").HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasColumnName("Foo").HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("UChilds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("UParentCollections").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.UChildRequired).WithMany().HasForeignKey("UChildRequiredId"); + modelBuilder.Entity().Navigation(e => e.UChildRequired).IsRequired(); + modelBuilder.Entity().Navigation(e => e.UChildRequired).HasField("_uChildRequired").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().HasOne(p => p.UChildOptional).WithMany().HasForeignKey("UChildOptionalId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.UChildOptional).HasField("_uChildOptional").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentOptional_UChildOptional_Id").OnDelete(DeleteBehavior.NoAction); - modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentOptional_UChildCollection_Id").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).HasDefaultValue("hello"); + modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentOptionalUChildOptionalId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.UChildOptional).HasField("_uChildOptional").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentOptionalUChildCollectionId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.UChildCollection).HasField("_uChildCollection").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UParentOptional", "UChildRequiredId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.UChildRequired).IsRequired(); + modelBuilder.Entity().Navigation(e => e.UChildRequired).HasField("_uChildRequired").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("UParentRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UChild", "UParentRequired_UChildRequired_Id").OnDelete(DeleteBehavior.NoAction); - modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentRequired_UChildCollection_Id").OnDelete(DeleteBehavior.NoAction).IsRequired(); - modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentRequired_UChildOptional_Id").OnDelete(DeleteBehavior.NoAction).IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UChild", "UParentRequiredUChildRequiredId").OnDelete(DeleteBehavior.NoAction).IsRequired(); + modelBuilder.Entity().Navigation(e => e.UChildRequired).HasField("_uChildRequired").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentRequiredUChildCollectionId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.UChildCollection).HasField("_uChildCollection").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentRequiredUChildOptionalId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.UChildOptional).HasField("_uChildOptional").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); OnModelCreatedImpl(modelBuilder); } diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/AbstractBaseClass.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/AbstractBaseClass.generated.cs index f506f1cf1..8118b33b2 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/AbstractBaseClass.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/AbstractBaseClass.generated.cs @@ -39,7 +39,6 @@ protected AbstractBaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/AllPropertyTypesOptional.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/AllPropertyTypesOptional.generated.cs index a31e28272..4ed270044 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/AllPropertyTypesOptional.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/AllPropertyTypesOptional.generated.cs @@ -47,7 +47,6 @@ public AllPropertyTypesOptional(int id1) this.Id1 = id1; this.OwnedType = new global::Testing.OwnedType(); - Init(); } @@ -90,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -596,8 +595,19 @@ public int Id1 * Navigation properties *************************************************************************/ + /// + /// Backing field for OwnedType + /// protected global::Testing.OwnedType _ownedType; + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before setting. + /// partial void SetOwnedType(global::Testing.OwnedType oldValue, ref global::Testing.OwnedType newValue); + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before returning. + /// partial void GetOwnedType(ref global::Testing.OwnedType result); public virtual global::Testing.OwnedType OwnedType diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/AllPropertyTypesRequired.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/AllPropertyTypesRequired.generated.cs index 965a5474b..bf799d306 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/AllPropertyTypesRequired.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/AllPropertyTypesRequired.generated.cs @@ -86,7 +86,6 @@ public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteat this.TimeAttr = timeattr; - Init(); } @@ -142,7 +141,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BChild.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BChild.generated.cs index 802976967..85481da8f 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BChild.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BChild.generated.cs @@ -32,9 +32,6 @@ protected BChild() BParentCollection = new System.Collections.Generic.HashSet(); BParentCollection_2 = new System.Collections.Generic.HashSet(); - BParentRequired = new global::Testing.BParentRequired(); - BParentRequired_1 = new global::Testing.BParentRequired(); - BParentRequired_2 = new global::Testing.BParentRequired(); Init(); } @@ -59,13 +56,14 @@ public BChild(global::Testing.BParentRequired bparentrequired, global::Testing.B if (bparentrequired == null) throw new ArgumentNullException(nameof(bparentrequired)); this.BParentRequired = bparentrequired; + bparentrequired.BChildOptional = this; if (bparentrequired_2 == null) throw new ArgumentNullException(nameof(bparentrequired_2)); this.BParentRequired_2 = bparentrequired_2; + bparentrequired_2.BChildCollection.Add(this); this.BParentCollection = new System.Collections.Generic.HashSet(); this.BParentCollection_2 = new System.Collections.Generic.HashSet(); - Init(); } @@ -109,7 +107,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BParentCollection.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BParentCollection.generated.cs index af5faf66c..cc0cc710b 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BParentCollection.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BParentCollection.generated.cs @@ -27,8 +27,6 @@ public partial class BParentCollection /// protected BParentCollection() { - BChildRequired = global::Testing.BChild.CreateBChildUnsafe(); - Init(); } @@ -48,7 +46,7 @@ public BParentCollection(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; - + bchildrequired.BParentCollection.Add(this); Init(); } @@ -92,7 +90,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -107,8 +105,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -133,8 +142,19 @@ protected set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BParentOptional.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BParentOptional.generated.cs index 8c4093fa7..df70b0bd3 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BParentOptional.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BParentOptional.generated.cs @@ -28,7 +28,6 @@ public partial class BParentOptional protected BParentOptional() { BChildCollection = new System.Collections.Generic.HashSet(); - BChildRequired = global::Testing.BChild.CreateBChildUnsafe(); Init(); } @@ -49,9 +48,9 @@ public BParentOptional(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; + bchildrequired.BParentOptional = this; this.BChildCollection = new System.Collections.Generic.HashSet(); - Init(); } @@ -94,7 +93,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -109,8 +108,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -135,7 +145,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get @@ -148,8 +162,19 @@ private set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BParentRequired.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BParentRequired.generated.cs index e9d71bdd2..43edc21ed 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BParentRequired.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BParentRequired.generated.cs @@ -28,7 +28,6 @@ public partial class BParentRequired public BParentRequired() { BChildCollection = new System.Collections.Generic.HashSet(); - BChildRequired = global::Testing.BChild.CreateBChildUnsafe(); Init(); } @@ -63,7 +62,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -78,8 +77,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional @@ -101,8 +111,19 @@ protected set } } + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -127,7 +148,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BaseClass.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BaseClass.generated.cs index 1e11e199e..ab595e96c 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BaseClass.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BaseClass.generated.cs @@ -47,7 +47,6 @@ public BaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BaseClassWithRequiredProperties.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BaseClassWithRequiredProperties.generated.cs index bb337a79e..557698cc4 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BaseClassWithRequiredProperties.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/BaseClassWithRequiredProperties.generated.cs @@ -47,7 +47,6 @@ public BaseClassWithRequiredProperties(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } @@ -90,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/Child.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/Child.generated.cs index 355e18745..51e6460e1 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/Child.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/Child.generated.cs @@ -28,7 +28,6 @@ public partial class Child protected Child() { Children = new System.Collections.Generic.HashSet(); - Parent = global::Testing.Child.CreateChildUnsafe(); Init(); } @@ -50,12 +49,12 @@ public Child(global::Testing.Child parent, global::Testing.Master _master0) { if (parent == null) throw new ArgumentNullException(nameof(parent)); this.Parent = parent; + parent.Children.Add(this); if (_master0 == null) throw new ArgumentNullException(nameof(_master0)); _master0.Children.Add(this); this.Children = new System.Collections.Generic.HashSet(); - Init(); } @@ -99,7 +98,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -114,7 +113,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/ConcreteDerivedClass.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/ConcreteDerivedClass.generated.cs index cee4e6783..b05619dd1 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/ConcreteDerivedClass.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/ConcreteDerivedClass.generated.cs @@ -47,7 +47,6 @@ public ConcreteDerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs index b3fa04fdb..84cd0bc5c 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs @@ -51,7 +51,6 @@ public ConcreteDerivedClassWithRequiredProperties(string property1, string prope if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/DerivedClass.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/DerivedClass.generated.cs index 33e54b6e6..59dd6f39f 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/DerivedClass.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/DerivedClass.generated.cs @@ -47,7 +47,6 @@ public DerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/HiddenEntity.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/HiddenEntity.generated.cs index caa5dcc02..3ae611794 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/HiddenEntity.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/HiddenEntity.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/Master.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/Master.generated.cs index fd5ed86b8..61807d30b 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/Master.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/Master.generated.cs @@ -62,7 +62,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -77,7 +77,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/OwnedType.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/OwnedType.generated.cs index 356934d5a..66af3d729 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/OwnedType.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/OwnedType.generated.cs @@ -39,7 +39,6 @@ public OwnedType(global::Testing.AllPropertyTypesOptional _allpropertytypesoptio if (_allpropertytypesoptional0 == null) throw new ArgumentNullException(nameof(_allpropertytypesoptional0)); _allpropertytypesoptional0.OwnedType = this; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/ParserTest.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/ParserTest.generated.cs index 261469691..aa8ab86c0 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/ParserTest.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/ParserTest.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/RenamedColumn.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/RenamedColumn.generated.cs index e12f1a4c5..97af66423 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/RenamedColumn.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/RenamedColumn.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/UChild.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/UChild.generated.cs index bc67ba3d7..9b1d7572d 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/UChild.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/UChild.generated.cs @@ -57,7 +57,6 @@ public UChild(global::Testing.UParentRequired _uparentrequired1, global::Testing if (_uparentrequired2 == null) throw new ArgumentNullException(nameof(_uparentrequired2)); _uparentrequired2.UChildOptional = this; - Init(); } @@ -101,7 +100,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/UParentCollection.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/UParentCollection.generated.cs index b2fe3516b..c49ce677e 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/UParentCollection.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/UParentCollection.generated.cs @@ -27,8 +27,6 @@ public partial class UParentCollection /// protected UParentCollection() { - UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); - Init(); } @@ -49,7 +47,6 @@ public UParentCollection(global::Testing.UChild uchildrequired) if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); this.UChildRequired = uchildrequired; - Init(); } @@ -92,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -107,8 +104,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -133,8 +141,19 @@ protected set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/UParentOptional.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/UParentOptional.generated.cs index e27bf7bb8..4fbc70b55 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/UParentOptional.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/UParentOptional.generated.cs @@ -29,7 +29,6 @@ protected UParentOptional(): base() { PropertyInChild = "hello"; UChildCollection = new System.Collections.Generic.HashSet(); - UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); Init(); } @@ -53,7 +52,6 @@ public UParentOptional(global::Testing.UChild uchildrequired) this.UChildRequired = uchildrequired; this.UChildCollection = new System.Collections.Generic.HashSet(); - Init(); } @@ -109,8 +107,19 @@ public string PropertyInChild * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional @@ -132,7 +141,11 @@ public string PropertyInChild } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -145,8 +158,19 @@ private set } } + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// diff --git a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/UParentRequired.generated.cs b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/UParentRequired.generated.cs index be5063e5f..c3bde8ef8 100644 --- a/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/UParentRequired.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetFramework/Generated/Entities/UParentRequired.generated.cs @@ -28,7 +28,6 @@ public partial class UParentRequired public UParentRequired() { UChildCollection = new System.Collections.Generic.HashSet(); - UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); Init(); } @@ -63,7 +62,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -78,8 +77,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -104,7 +114,11 @@ protected set } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -117,8 +131,19 @@ private set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/AllFeatureModel.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/AllFeatureModel.cs index 6153a7d78..47021ebc9 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/AllFeatureModel.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/AllFeatureModel.cs @@ -1 +1,1851 @@  +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class AllPropertyTypesRequired + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesRequired() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesRequired CreateAllPropertyTypesRequiredUnsafe() + { + return new AllPropertyTypesRequired(); + } + + /// + /// Public constructor with required data + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, string stringattr, TimeSpan timeattr) + { + this.BinaryAttr = binaryattr; + + this.BooleanAttr = booleanattr; + + this.ByteAttr = byteattr; + + this.DateTimeAttr = datetimeattr; + + this.DateTimeOffsetAttr = datetimeoffsetattr; + + this.DecimalAttr = decimalattr; + + this.DoubleAttr = doubleattr; + + this.GuidAttr = guidattr; + + this.Int16Attr = int16attr; + + this.Int32Attr = int32attr; + + this.Int64Attr = int64attr; + + this.SingleAttr = singleattr; + + if (string.IsNullOrEmpty(stringattr)) throw new ArgumentNullException(nameof(stringattr)); + this.StringAttr = stringattr; + + this.TimeAttr = timeattr; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static AllPropertyTypesRequired Create(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, string stringattr, TimeSpan timeattr) + { + return new AllPropertyTypesRequired(binaryattr, booleanattr, byteattr, datetimeattr, datetimeoffsetattr, decimalattr, doubleattr, guidattr, int16attr, int32attr, int64attr, singleattr, stringattr, timeattr); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + /// + /// Required + /// + [Required] + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool oldValue, ref bool newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool result); + + /// + /// Required + /// + [Required] + public bool BooleanAttr + { + get + { + bool value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte oldValue, ref byte newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte result); + + /// + /// Required + /// + [Required] + public byte ByteAttr + { + get + { + byte value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime oldValue, ref DateTime newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime result); + + /// + /// Required + /// + [Required] + public DateTime DateTimeAttr + { + get + { + DateTime value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset oldValue, ref DateTimeOffset newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset result); + + /// + /// Required + /// + [Required] + public DateTimeOffset DateTimeOffsetAttr + { + get + { + DateTimeOffset value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal oldValue, ref decimal newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal result); + + /// + /// Required + /// + [Required] + public decimal DecimalAttr + { + get + { + decimal value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double oldValue, ref double newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double result); + + /// + /// Required + /// + [Required] + public double DoubleAttr + { + get + { + double value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid oldValue, ref Guid newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid result); + + /// + /// Required + /// + [Required] + public Guid GuidAttr + { + get + { + Guid value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short oldValue, ref short newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short result); + + /// + /// Required + /// + [Required] + public short Int16Attr + { + get + { + short value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int result); + + /// + /// Required + /// + [Required] + public int Int32Attr + { + get + { + int value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long oldValue, ref long newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long result); + + /// + /// Required + /// + [Required] + public long Int64Attr + { + get + { + long value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single oldValue, ref Single newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single result); + + /// + /// Required + /// + [Required] + public Single SingleAttr + { + get + { + Single value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + /// + /// Required + /// + [Required] + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan oldValue, ref TimeSpan newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan result); + + /// + /// Required + /// + [Required] + public TimeSpan TimeAttr + { + get + { + TimeSpan value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class AllPropertyTypesOptional + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesOptional() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesOptional CreateAllPropertyTypesOptionalUnsafe() + { + return new AllPropertyTypesOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public AllPropertyTypesOptional(int id1) + { + this.Id1 = id1; + + this.OwnedType = new global::Testing.OwnedType(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static AllPropertyTypesOptional Create(int id1) + { + return new AllPropertyTypesOptional(id1); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool? _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool? oldValue, ref bool? newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool? result); + + public bool? BooleanAttr + { + get + { + bool? value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool? oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte? _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte? oldValue, ref byte? newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte? result); + + public byte? ByteAttr + { + get + { + byte? value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte? oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime? _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime? oldValue, ref DateTime? newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime? result); + + public DateTime? DateTimeAttr + { + get + { + DateTime? value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime? oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset? _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset? oldValue, ref DateTimeOffset? newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset? result); + + public DateTimeOffset? DateTimeOffsetAttr + { + get + { + DateTimeOffset? value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset? oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal? _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal? oldValue, ref decimal? newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal? result); + + public decimal? DecimalAttr + { + get + { + decimal? value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal? oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double? _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double? oldValue, ref double? newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double? result); + + public double? DoubleAttr + { + get + { + double? value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double? oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid? _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid? oldValue, ref Guid? newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid? result); + + public Guid? GuidAttr + { + get + { + Guid? value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid? oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short? _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short? oldValue, ref short? newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short? result); + + public short? Int16Attr + { + get + { + short? value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short? oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int? _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int? oldValue, ref int? newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int? result); + + public int? Int32Attr + { + get + { + int? value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int? oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long? _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long? oldValue, ref long? newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long? result); + + public long? Int64Attr + { + get + { + long? value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long? oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single? _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single? oldValue, ref Single? newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single? result); + + public Single? SingleAttr + { + get + { + Single? value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single? oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan? _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan? oldValue, ref TimeSpan? newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan? result); + + public TimeSpan? TimeAttr + { + get + { + TimeSpan? value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan? oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + /// + /// Backing field for Id1 + /// + internal int _id1; + /// + /// When provided in a partial class, allows value of Id1 to be changed before setting. + /// + partial void SetId1(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id1 to be changed before returning. + /// + partial void GetId1(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id1 + { + get + { + int value = _id1; + GetId1(ref value); + return (_id1 = value); + } + set + { + int oldValue = _id1; + SetId1(oldValue, ref value); + if (oldValue != value) + { + _id1 = value; + } + } + } + + /// + /// Concurrency token + /// + [Timestamp] + public Byte[] Timestamp { get; set; } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for OwnedType + /// + protected global::Testing.OwnedType _ownedType; + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before setting. + /// + partial void SetOwnedType(global::Testing.OwnedType oldValue, ref global::Testing.OwnedType newValue); + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before returning. + /// + partial void GetOwnedType(ref global::Testing.OwnedType result); + + public virtual global::Testing.OwnedType OwnedType + { + get + { + global::Testing.OwnedType value = _ownedType; + GetOwnedType(ref value); + return (_ownedType = value); + } + set + { + global::Testing.OwnedType oldValue = _ownedType; + SetOwnedType(oldValue, ref value); + if (oldValue != value) + { + _ownedType = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentRequired + { + partial void Init(); + + /// + /// Default constructor + /// + public UParentRequired() + { + UChildCollection = new System.Collections.Generic.HashSet(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentOptional: global::Testing.HiddenEntity + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentOptional(): base() + { + PropertyInChild = "hello"; + UChildCollection = new System.Collections.Generic.HashSet(); + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentOptional CreateUParentOptionalUnsafe() + { + return new UParentOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentOptional(global::Testing.UChild uchildrequired) + { + this.PropertyInChild = "hello"; + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + this.UChildCollection = new System.Collections.Generic.HashSet(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentOptional Create(global::Testing.UChild uchildrequired) + { + return new UParentOptional(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for PropertyInChild + /// + protected string _propertyInChild; + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before setting. + /// + partial void SetPropertyInChild(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before returning. + /// + partial void GetPropertyInChild(ref string result); + + /// + /// Default value = "hello" + /// + public string PropertyInChild + { + get + { + string value = _propertyInChild; + GetPropertyInChild(ref value); + return (_propertyInChild = value); + } + set + { + string oldValue = _propertyInChild; + SetPropertyInChild(oldValue, ref value); + if (oldValue != value) + { + _propertyInChild = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentCollection + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentCollection() + { + UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentCollection CreateUParentCollectionUnsafe() + { + return new UParentCollection(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentCollection(global::Testing.UChild uchildrequired) + { + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentCollection Create(global::Testing.UChild uchildrequired) + { + return new UParentCollection(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UChild + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UChild() + { + // NOTE: This class has one-to-one associations with UChild. + // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other. + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UChild CreateUChildUnsafe() + { + return new UChild(); + } + + /// + /// Public constructor with required data + /// diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Context/AllFeatureModel.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Context/AllFeatureModel.generated.cs index a7b1a41f8..96e25ec93 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Context/AllFeatureModel.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Context/AllFeatureModel.generated.cs @@ -76,7 +76,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().ToTable("AllPropertyTypesOptionals").HasKey(t => new { t.Id, t.Id1 }); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.BinaryAttr).HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.BooleanAttr).HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.ByteAttr).HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); @@ -91,76 +91,83 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.SingleAttr).HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.StringAttr).HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.TimeAttr).HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Id1).IsRequired().HasField("_id1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever(); + modelBuilder.Entity().Property(t => t.Id1).HasField("_id1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever().IsRequired(); modelBuilder.Entity().Property("Timestamp").IsConcurrencyToken(); modelBuilder.Entity().OwnsOne(p => p.OwnedType).Property(p => p.SingleAttr); modelBuilder.Entity().ToTable("AllPropertyTypesRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().Property(t => t.BinaryAttr).IsRequired().HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.BooleanAttr).IsRequired().HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.ByteAttr).IsRequired().HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DateTimeAttr).IsRequired().HasField("_dateTimeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DateTimeOffsetAttr).IsRequired().HasField("_dateTimeOffsetAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DecimalAttr).IsRequired().HasField("_decimalAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DoubleAttr).IsRequired().HasField("_doubleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.GuidAttr).IsRequired().HasField("_guidAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int16Attr).IsRequired().HasField("_int16Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int32Attr).IsRequired().HasField("_int32Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int64Attr).IsRequired().HasField("_int64Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.SingleAttr).IsRequired().HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.StringAttr).IsRequired().HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.TimeAttr).IsRequired().HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().Property(t => t.BinaryAttr).HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.BooleanAttr).HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.ByteAttr).HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DateTimeAttr).HasField("_dateTimeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DateTimeOffsetAttr).HasField("_dateTimeOffsetAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DecimalAttr).HasField("_decimalAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DoubleAttr).HasField("_doubleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.GuidAttr).HasField("_guidAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int16Attr).HasField("_int16Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int32Attr).HasField("_int32Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int64Attr).HasField("_int64Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.SingleAttr).HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.StringAttr).HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.TimeAttr).HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().ToTable("BaseClassWithRequiredProperties").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().Property(t => t.Property0).IsRequired().HasField("_property0").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().Property(t => t.Property0).HasField("_property0").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().ToTable("BChilds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("BParentCollections").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithMany(p => p.BParentCollection).HasForeignKey("BChildRequiredId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.BChildRequired).IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithMany(p => p.BParentCollection_2).HasForeignKey("BChildOptionalId").OnDelete(DeleteBehavior.NoAction); modelBuilder.Entity().ToTable("BParentOptionals").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentOptional).HasForeignKey("BParentOptional", "BChildRequiredId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.BChildRequired).IsRequired(); modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentOptional_1).HasForeignKey("BParentOptional_1Id").OnDelete(DeleteBehavior.NoAction); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentOptional_2).HasForeignKey("BChild", "BParentOptional_2Id").OnDelete(DeleteBehavior.NoAction); modelBuilder.Entity().ToTable("BParentRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentRequired).HasForeignKey("BChild", "BParentRequiredId").OnDelete(DeleteBehavior.NoAction).IsRequired(); - modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentRequired_1).HasForeignKey("BChild", "BParentRequired_1Id").OnDelete(DeleteBehavior.NoAction); - modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentRequired_2).HasForeignKey("BParentRequired_2Id").OnDelete(DeleteBehavior.NoAction).IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentRequired).HasForeignKey("BChild", "BParentRequiredId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.BParentRequired).IsRequired(); + modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentRequired_1).HasForeignKey("BChild", "BParentRequired_1Id").OnDelete(DeleteBehavior.NoAction).IsRequired(); + modelBuilder.Entity().Navigation(e => e.BParentRequired_1).IsRequired(); + modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentRequired_2).HasForeignKey("BParentRequired_2Id").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.BParentRequired_2).IsRequired(); modelBuilder.Entity().ToTable("Children").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasMany(p => p.Children).WithOne(p => p.Parent).HasForeignKey("ParentId").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasMany(p => p.Children).WithOne(p => p.Parent).HasForeignKey("ParentId"); + modelBuilder.Entity().Navigation(e => e.Parent).IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Property1).IsRequired().HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("HiddenEntities").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("Masters").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasMany(p => p.Children).WithOne().HasForeignKey("Master_Children_Id").OnDelete(DeleteBehavior.NoAction).IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasMany(p => p.Children).WithOne().HasForeignKey("MasterChildrenId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.Children).HasField("_children").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Owned(); modelBuilder.Entity().ToTable("ParserTests").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.name1).HasField("_name1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.name2).HasField("_name2").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.name3).HasField("_name3").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); @@ -181,26 +188,36 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.name18).HasField("_name18").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("RenamedColumns").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasColumnName("Foo").HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasColumnName("Foo").HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("UChilds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("UParentCollections").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.UChildRequired).WithMany().HasForeignKey("UChildRequiredId"); + modelBuilder.Entity().Navigation(e => e.UChildRequired).IsRequired(); + modelBuilder.Entity().Navigation(e => e.UChildRequired).HasField("_uChildRequired").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().HasOne(p => p.UChildOptional).WithMany().HasForeignKey("UChildOptionalId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.UChildOptional).HasField("_uChildOptional").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentOptional_UChildOptional_Id").OnDelete(DeleteBehavior.NoAction); - modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentOptional_UChildCollection_Id").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).HasDefaultValue("hello"); + modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentOptionalUChildOptionalId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.UChildOptional).HasField("_uChildOptional").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentOptionalUChildCollectionId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.UChildCollection).HasField("_uChildCollection").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UParentOptional", "UChildRequiredId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.UChildRequired).IsRequired(); + modelBuilder.Entity().Navigation(e => e.UChildRequired).HasField("_uChildRequired").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("UParentRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UChild", "UParentRequired_UChildRequired_Id").OnDelete(DeleteBehavior.NoAction); - modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentRequired_UChildCollection_Id").OnDelete(DeleteBehavior.NoAction).IsRequired(); - modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentRequired_UChildOptional_Id").OnDelete(DeleteBehavior.NoAction).IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UChild", "UParentRequiredUChildRequiredId").OnDelete(DeleteBehavior.NoAction).IsRequired(); + modelBuilder.Entity().Navigation(e => e.UChildRequired).HasField("_uChildRequired").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentRequiredUChildCollectionId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.UChildCollection).HasField("_uChildCollection").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentRequiredUChildOptionalId").OnDelete(DeleteBehavior.NoAction); + modelBuilder.Entity().Navigation(e => e.UChildOptional).HasField("_uChildOptional").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); OnModelCreatedImpl(modelBuilder); } diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/AbstractBaseClass.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/AbstractBaseClass.generated.cs index f506f1cf1..8118b33b2 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/AbstractBaseClass.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/AbstractBaseClass.generated.cs @@ -39,7 +39,6 @@ protected AbstractBaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/AllPropertyTypesOptional.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/AllPropertyTypesOptional.generated.cs index a31e28272..4ed270044 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/AllPropertyTypesOptional.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/AllPropertyTypesOptional.generated.cs @@ -47,7 +47,6 @@ public AllPropertyTypesOptional(int id1) this.Id1 = id1; this.OwnedType = new global::Testing.OwnedType(); - Init(); } @@ -90,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -596,8 +595,19 @@ public int Id1 * Navigation properties *************************************************************************/ + /// + /// Backing field for OwnedType + /// protected global::Testing.OwnedType _ownedType; + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before setting. + /// partial void SetOwnedType(global::Testing.OwnedType oldValue, ref global::Testing.OwnedType newValue); + + /// + /// When provided in a partial class, allows value of OwnedType to be changed before returning. + /// partial void GetOwnedType(ref global::Testing.OwnedType result); public virtual global::Testing.OwnedType OwnedType diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/AllPropertyTypesRequired.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/AllPropertyTypesRequired.generated.cs index 965a5474b..bf799d306 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/AllPropertyTypesRequired.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/AllPropertyTypesRequired.generated.cs @@ -86,7 +86,6 @@ public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteat this.TimeAttr = timeattr; - Init(); } @@ -142,7 +141,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BChild.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BChild.generated.cs index 802976967..85481da8f 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BChild.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BChild.generated.cs @@ -32,9 +32,6 @@ protected BChild() BParentCollection = new System.Collections.Generic.HashSet(); BParentCollection_2 = new System.Collections.Generic.HashSet(); - BParentRequired = new global::Testing.BParentRequired(); - BParentRequired_1 = new global::Testing.BParentRequired(); - BParentRequired_2 = new global::Testing.BParentRequired(); Init(); } @@ -59,13 +56,14 @@ public BChild(global::Testing.BParentRequired bparentrequired, global::Testing.B if (bparentrequired == null) throw new ArgumentNullException(nameof(bparentrequired)); this.BParentRequired = bparentrequired; + bparentrequired.BChildOptional = this; if (bparentrequired_2 == null) throw new ArgumentNullException(nameof(bparentrequired_2)); this.BParentRequired_2 = bparentrequired_2; + bparentrequired_2.BChildCollection.Add(this); this.BParentCollection = new System.Collections.Generic.HashSet(); this.BParentCollection_2 = new System.Collections.Generic.HashSet(); - Init(); } @@ -109,7 +107,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BParentCollection.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BParentCollection.generated.cs index af5faf66c..cc0cc710b 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BParentCollection.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BParentCollection.generated.cs @@ -27,8 +27,6 @@ public partial class BParentCollection /// protected BParentCollection() { - BChildRequired = global::Testing.BChild.CreateBChildUnsafe(); - Init(); } @@ -48,7 +46,7 @@ public BParentCollection(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; - + bchildrequired.BParentCollection.Add(this); Init(); } @@ -92,7 +90,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -107,8 +105,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -133,8 +142,19 @@ protected set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BParentOptional.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BParentOptional.generated.cs index 8c4093fa7..df70b0bd3 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BParentOptional.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BParentOptional.generated.cs @@ -28,7 +28,6 @@ public partial class BParentOptional protected BParentOptional() { BChildCollection = new System.Collections.Generic.HashSet(); - BChildRequired = global::Testing.BChild.CreateBChildUnsafe(); Init(); } @@ -49,9 +48,9 @@ public BParentOptional(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; + bchildrequired.BParentOptional = this; this.BChildCollection = new System.Collections.Generic.HashSet(); - Init(); } @@ -94,7 +93,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -109,8 +108,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -135,7 +145,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get @@ -148,8 +162,19 @@ private set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BParentRequired.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BParentRequired.generated.cs index e9d71bdd2..43edc21ed 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BParentRequired.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BParentRequired.generated.cs @@ -28,7 +28,6 @@ public partial class BParentRequired public BParentRequired() { BChildCollection = new System.Collections.Generic.HashSet(); - BChildRequired = global::Testing.BChild.CreateBChildUnsafe(); Init(); } @@ -63,7 +62,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -78,8 +77,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional @@ -101,8 +111,19 @@ protected set } } + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -127,7 +148,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BaseClass.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BaseClass.generated.cs index 1e11e199e..ab595e96c 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BaseClass.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BaseClass.generated.cs @@ -47,7 +47,6 @@ public BaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BaseClassWithRequiredProperties.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BaseClassWithRequiredProperties.generated.cs index bb337a79e..557698cc4 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BaseClassWithRequiredProperties.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/BaseClassWithRequiredProperties.generated.cs @@ -47,7 +47,6 @@ public BaseClassWithRequiredProperties(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } @@ -90,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/Child.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/Child.generated.cs index 355e18745..51e6460e1 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/Child.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/Child.generated.cs @@ -28,7 +28,6 @@ public partial class Child protected Child() { Children = new System.Collections.Generic.HashSet(); - Parent = global::Testing.Child.CreateChildUnsafe(); Init(); } @@ -50,12 +49,12 @@ public Child(global::Testing.Child parent, global::Testing.Master _master0) { if (parent == null) throw new ArgumentNullException(nameof(parent)); this.Parent = parent; + parent.Children.Add(this); if (_master0 == null) throw new ArgumentNullException(nameof(_master0)); _master0.Children.Add(this); this.Children = new System.Collections.Generic.HashSet(); - Init(); } @@ -99,7 +98,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -114,7 +113,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/ConcreteDerivedClass.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/ConcreteDerivedClass.generated.cs index cee4e6783..b05619dd1 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/ConcreteDerivedClass.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/ConcreteDerivedClass.generated.cs @@ -47,7 +47,6 @@ public ConcreteDerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs index b3fa04fdb..84cd0bc5c 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs @@ -51,7 +51,6 @@ public ConcreteDerivedClassWithRequiredProperties(string property1, string prope if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/DerivedClass.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/DerivedClass.generated.cs index 33e54b6e6..59dd6f39f 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/DerivedClass.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/DerivedClass.generated.cs @@ -47,7 +47,6 @@ public DerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/HiddenEntity.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/HiddenEntity.generated.cs index caa5dcc02..3ae611794 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/HiddenEntity.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/HiddenEntity.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/Master.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/Master.generated.cs index fd5ed86b8..61807d30b 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/Master.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/Master.generated.cs @@ -62,7 +62,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -77,7 +77,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/OwnedType.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/OwnedType.generated.cs index 356934d5a..66af3d729 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/OwnedType.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/OwnedType.generated.cs @@ -39,7 +39,6 @@ public OwnedType(global::Testing.AllPropertyTypesOptional _allpropertytypesoptio if (_allpropertytypesoptional0 == null) throw new ArgumentNullException(nameof(_allpropertytypesoptional0)); _allpropertytypesoptional0.OwnedType = this; - Init(); } diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/ParserTest.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/ParserTest.generated.cs index 261469691..aa8ab86c0 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/ParserTest.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/ParserTest.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/RenamedColumn.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/RenamedColumn.generated.cs index e12f1a4c5..97af66423 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/RenamedColumn.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/RenamedColumn.generated.cs @@ -60,7 +60,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/UChild.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/UChild.generated.cs index bc67ba3d7..9b1d7572d 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/UChild.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/UChild.generated.cs @@ -57,7 +57,6 @@ public UChild(global::Testing.UParentRequired _uparentrequired1, global::Testing if (_uparentrequired2 == null) throw new ArgumentNullException(nameof(_uparentrequired2)); _uparentrequired2.UChildOptional = this; - Init(); } @@ -101,7 +100,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/UParentCollection.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/UParentCollection.generated.cs index b2fe3516b..c49ce677e 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/UParentCollection.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/UParentCollection.generated.cs @@ -27,8 +27,6 @@ public partial class UParentCollection /// protected UParentCollection() { - UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); - Init(); } @@ -49,7 +47,6 @@ public UParentCollection(global::Testing.UChild uchildrequired) if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); this.UChildRequired = uchildrequired; - Init(); } @@ -92,7 +89,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -107,8 +104,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -133,8 +141,19 @@ protected set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/UParentOptional.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/UParentOptional.generated.cs index e27bf7bb8..4fbc70b55 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/UParentOptional.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/UParentOptional.generated.cs @@ -29,7 +29,6 @@ protected UParentOptional(): base() { PropertyInChild = "hello"; UChildCollection = new System.Collections.Generic.HashSet(); - UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); Init(); } @@ -53,7 +52,6 @@ public UParentOptional(global::Testing.UChild uchildrequired) this.UChildRequired = uchildrequired; this.UChildCollection = new System.Collections.Generic.HashSet(); - Init(); } @@ -109,8 +107,19 @@ public string PropertyInChild * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional @@ -132,7 +141,11 @@ public string PropertyInChild } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -145,8 +158,19 @@ private set } } + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// diff --git a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/UParentRequired.generated.cs b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/UParentRequired.generated.cs index be5063e5f..c3bde8ef8 100644 --- a/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/UParentRequired.generated.cs +++ b/src/Testing/EFCoreV3/EFCore3NetStandard/Generated/Entities/UParentRequired.generated.cs @@ -28,7 +28,6 @@ public partial class UParentRequired public UParentRequired() { UChildCollection = new System.Collections.Generic.HashSet(); - UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); Init(); } @@ -63,7 +62,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -78,8 +77,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -104,7 +114,11 @@ protected set } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -117,8 +131,19 @@ private set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EFCoreV5/EFCore5Net5/Generated/EFModel1.generated.cs b/src/Testing/EFCoreV5/EFCore5Net5/Generated/EFModel1.generated.cs index bf9866116..f48351b07 100644 --- a/src/Testing/EFCoreV5/EFCore5Net5/Generated/EFModel1.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5Net5/Generated/EFModel1.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.1.0 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -35,7 +35,7 @@ public partial class EFModel1 : DbContext /// /// Default connection string /// - public static string ConnectionString { get; set; } = @"Data Source=(localdb)\MSSQLLocalDb;Initial Catalog=Test;Integrated Security=True"; + public static string ConnectionString { get; set; } = @"Data Source=.\sqlexpress;Initial Catalog=Test;Integrated Security=True"; /// public EFModel1(DbContextOptions options) : base(options) @@ -47,6 +47,8 @@ public EFModel1(DbContextOptions options) : base(options) /// protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { + optionsBuilder.UseLazyLoadingProxies(); + CustomInit(optionsBuilder); } @@ -66,12 +68,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasKey(t => t.Id); modelBuilder.Entity() .Property(t => t.Id) - .IsRequired() - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .IsRequired(); modelBuilder.Entity() .HasOne(p => p.EntityImplementation) .WithOne(p => p.Entity1) - .HasForeignKey("Entity1", "EntityImplementationId"); + .HasForeignKey("Entity1", "EntityImplementationId") + .OnDelete(DeleteBehavior.Cascade); modelBuilder.Entity().Navigation(e => e.EntityImplementation).IsRequired(); modelBuilder.Entity() @@ -79,8 +82,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasKey(t => t.Id); modelBuilder.Entity() .Property(t => t.Id) - .IsRequired() - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .IsRequired(); modelBuilder.Entity() .Property(t => t.Test) @@ -91,8 +94,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasKey(t => t.Id); modelBuilder.Entity() .Property(t => t.Id) - .IsRequired() - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .IsRequired(); modelBuilder.Entity() .HasOne(p => p.EntityAbstract) .WithMany(p => p.EntityRelated) diff --git a/src/Testing/EFCoreV5/EFCore5Net5/Generated/Entity1.generated.cs b/src/Testing/EFCoreV5/EFCore5Net5/Generated/Entity1.generated.cs index 461fc2f12..799f45852 100644 --- a/src/Testing/EFCoreV5/EFCore5Net5/Generated/Entity1.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5Net5/Generated/Entity1.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.1.0 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -33,8 +33,6 @@ public partial class Entity1 /// protected Entity1() { - EntityImplementation = new global::Testing.EntityImplementation(); - Init(); } @@ -54,7 +52,7 @@ public Entity1(global::Testing.EntityImplementation entityimplementation) { if (entityimplementation == null) throw new ArgumentNullException(nameof(entityimplementation)); this.EntityImplementation = entityimplementation; - + entityimplementation.Entity1 = this; Init(); } @@ -78,7 +76,8 @@ public static Entity1 Create(global::Testing.EntityImplementation entityimplemen /// [Key] [Required] - public long Id { get; protected set; } + [System.ComponentModel.Description("Unique identifier")] + public long Id { get; set; } /************************************************************************* * Navigation properties diff --git a/src/Testing/EFCoreV5/EFCore5Net5/Generated/EntityAbstract.generated.cs b/src/Testing/EFCoreV5/EFCore5Net5/Generated/EntityAbstract.generated.cs index 210558dfb..5899f29ef 100644 --- a/src/Testing/EFCoreV5/EFCore5Net5/Generated/EntityAbstract.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5Net5/Generated/EntityAbstract.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.1.0 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -47,7 +47,7 @@ protected EntityAbstract() /// [Key] [Required] - public long Id { get; protected set; } + public long Id { get; set; } /************************************************************************* * Navigation properties diff --git a/src/Testing/EFCoreV5/EFCore5Net5/Generated/EntityImplementation.generated.cs b/src/Testing/EFCoreV5/EFCore5Net5/Generated/EntityImplementation.generated.cs index 686a41b61..e76575f8f 100644 --- a/src/Testing/EFCoreV5/EFCore5Net5/Generated/EntityImplementation.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5Net5/Generated/EntityImplementation.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.1.0 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -33,8 +33,6 @@ public partial class EntityImplementation: global::Testing.EntityAbstract /// public EntityImplementation(): base() { - Entity1 = global::Testing.Entity1.CreateEntity1Unsafe(); - Init(); } diff --git a/src/Testing/EFCoreV5/EFCore5Net5/Generated/EntityRelated.generated.cs b/src/Testing/EFCoreV5/EFCore5Net5/Generated/EntityRelated.generated.cs index 0bf7e1ae4..a13f84d8d 100644 --- a/src/Testing/EFCoreV5/EFCore5Net5/Generated/EntityRelated.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5Net5/Generated/EntityRelated.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.1.0 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -33,8 +33,6 @@ public partial class EntityRelated /// protected EntityRelated() { - // Assignment of required association EntityAbstract EntityAbstract was not generated because EntityAbstract is abstract. This must be assigned with a concrete object before saving. - Init(); } @@ -54,7 +52,7 @@ public EntityRelated(global::Testing.EntityAbstract entityabstract) { if (entityabstract == null) throw new ArgumentNullException(nameof(entityabstract)); this.EntityAbstract = entityabstract; - + entityabstract.EntityRelated.Add(this); Init(); } @@ -77,7 +75,7 @@ public static EntityRelated Create(global::Testing.EntityAbstract entityabstract /// [Key] [Required] - public long Id { get; protected set; } + public long Id { get; set; } /************************************************************************* * Navigation properties diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/AllFeatureModel.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/AllFeatureModel.cs index 6153a7d78..402d463fb 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/AllFeatureModel.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/AllFeatureModel.cs @@ -1 +1,1755 @@  +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +// Produced by Entity Framework Visual Editor v3.0.4.5 +// Source: https://github.com/msawczyn/EFDesigner +// Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner +// Documentation: https://msawczyn.github.io/EFDesigner/ +// License (MIT): https://github.com/msawczyn/EFDesigner/blob/master/LICENSE +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class AllPropertyTypesRequired + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected AllPropertyTypesRequired() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static AllPropertyTypesRequired CreateAllPropertyTypesRequiredUnsafe() + { + return new AllPropertyTypesRequired(); + } + + /// + /// Public constructor with required data + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, TimeSpan timeattr, string stringattr) + { + this.BinaryAttr = binaryattr; + + this.BooleanAttr = booleanattr; + + this.ByteAttr = byteattr; + + this.DateTimeAttr = datetimeattr; + + this.DateTimeOffsetAttr = datetimeoffsetattr; + + this.DecimalAttr = decimalattr; + + this.DoubleAttr = doubleattr; + + this.GuidAttr = guidattr; + + this.Int16Attr = int16attr; + + this.Int32Attr = int32attr; + + this.Int64Attr = int64attr; + + this.SingleAttr = singleattr; + + this.TimeAttr = timeattr; + + if (string.IsNullOrEmpty(stringattr)) throw new ArgumentNullException(nameof(stringattr)); + this.StringAttr = stringattr; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static AllPropertyTypesRequired Create(byte[] binaryattr, bool booleanattr, byte byteattr, DateTime datetimeattr, DateTimeOffset datetimeoffsetattr, decimal decimalattr, double doubleattr, Guid guidattr, short int16attr, int int32attr, long int64attr, Single singleattr, TimeSpan timeattr, string stringattr) + { + return new AllPropertyTypesRequired(binaryattr, booleanattr, byteattr, datetimeattr, datetimeoffsetattr, decimalattr, doubleattr, guidattr, int16attr, int32attr, int64attr, singleattr, timeattr, stringattr); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + protected int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + /// + /// Required + /// + [Required] + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool oldValue, ref bool newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool result); + + /// + /// Required + /// + [Required] + public bool BooleanAttr + { + get + { + bool value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte oldValue, ref byte newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte result); + + /// + /// Required + /// + [Required] + public byte ByteAttr + { + get + { + byte value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime oldValue, ref DateTime newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime result); + + /// + /// Required + /// + [Required] + public DateTime DateTimeAttr + { + get + { + DateTime value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset oldValue, ref DateTimeOffset newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset result); + + /// + /// Required + /// + [Required] + public DateTimeOffset DateTimeOffsetAttr + { + get + { + DateTimeOffset value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal oldValue, ref decimal newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal result); + + /// + /// Required + /// + [Required] + public decimal DecimalAttr + { + get + { + decimal value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double oldValue, ref double newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double result); + + /// + /// Required + /// + [Required] + public double DoubleAttr + { + get + { + double value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid oldValue, ref Guid newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid result); + + /// + /// Required + /// + [Required] + public Guid GuidAttr + { + get + { + Guid value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short oldValue, ref short newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short result); + + /// + /// Required + /// + [Required] + public short Int16Attr + { + get + { + short value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int result); + + /// + /// Required + /// + [Required] + public int Int32Attr + { + get + { + int value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long oldValue, ref long newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long result); + + /// + /// Required + /// + [Required] + public long Int64Attr + { + get + { + long value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single oldValue, ref Single newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single result); + + /// + /// Required + /// + [Required] + public Single SingleAttr + { + get + { + Single value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan oldValue, ref TimeSpan newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan result); + + /// + /// Required + /// + [Required] + public TimeSpan TimeAttr + { + get + { + TimeSpan value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + /// + /// Required + /// + [Required] + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class AllPropertyTypesOptional + { + partial void Init(); + + /// + /// Default constructor + /// + public AllPropertyTypesOptional() + { + Init(); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + protected int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /// + /// Backing field for BinaryAttr + /// + protected byte[] _binaryAttr; + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before setting. + /// + partial void SetBinaryAttr(byte[] oldValue, ref byte[] newValue); + /// + /// When provided in a partial class, allows value of BinaryAttr to be changed before returning. + /// + partial void GetBinaryAttr(ref byte[] result); + + public byte[] BinaryAttr + { + get + { + byte[] value = _binaryAttr; + GetBinaryAttr(ref value); + return (_binaryAttr = value); + } + set + { + byte[] oldValue = _binaryAttr; + SetBinaryAttr(oldValue, ref value); + if (oldValue != value) + { + _binaryAttr = value; + } + } + } + + /// + /// Backing field for BooleanAttr + /// + protected bool? _booleanAttr; + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before setting. + /// + partial void SetBooleanAttr(bool? oldValue, ref bool? newValue); + /// + /// When provided in a partial class, allows value of BooleanAttr to be changed before returning. + /// + partial void GetBooleanAttr(ref bool? result); + + public bool? BooleanAttr + { + get + { + bool? value = _booleanAttr; + GetBooleanAttr(ref value); + return (_booleanAttr = value); + } + set + { + bool? oldValue = _booleanAttr; + SetBooleanAttr(oldValue, ref value); + if (oldValue != value) + { + _booleanAttr = value; + } + } + } + + /// + /// Backing field for ByteAttr + /// + protected byte? _byteAttr; + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before setting. + /// + partial void SetByteAttr(byte? oldValue, ref byte? newValue); + /// + /// When provided in a partial class, allows value of ByteAttr to be changed before returning. + /// + partial void GetByteAttr(ref byte? result); + + public byte? ByteAttr + { + get + { + byte? value = _byteAttr; + GetByteAttr(ref value); + return (_byteAttr = value); + } + set + { + byte? oldValue = _byteAttr; + SetByteAttr(oldValue, ref value); + if (oldValue != value) + { + _byteAttr = value; + } + } + } + + /// + /// Backing field for DateTimeAttr + /// + protected DateTime? _dateTimeAttr; + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before setting. + /// + partial void SetDateTimeAttr(DateTime? oldValue, ref DateTime? newValue); + /// + /// When provided in a partial class, allows value of DateTimeAttr to be changed before returning. + /// + partial void GetDateTimeAttr(ref DateTime? result); + + public DateTime? DateTimeAttr + { + get + { + DateTime? value = _dateTimeAttr; + GetDateTimeAttr(ref value); + return (_dateTimeAttr = value); + } + set + { + DateTime? oldValue = _dateTimeAttr; + SetDateTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeAttr = value; + } + } + } + + /// + /// Backing field for DateTimeOffsetAttr + /// + protected DateTimeOffset? _dateTimeOffsetAttr; + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before setting. + /// + partial void SetDateTimeOffsetAttr(DateTimeOffset? oldValue, ref DateTimeOffset? newValue); + /// + /// When provided in a partial class, allows value of DateTimeOffsetAttr to be changed before returning. + /// + partial void GetDateTimeOffsetAttr(ref DateTimeOffset? result); + + public DateTimeOffset? DateTimeOffsetAttr + { + get + { + DateTimeOffset? value = _dateTimeOffsetAttr; + GetDateTimeOffsetAttr(ref value); + return (_dateTimeOffsetAttr = value); + } + set + { + DateTimeOffset? oldValue = _dateTimeOffsetAttr; + SetDateTimeOffsetAttr(oldValue, ref value); + if (oldValue != value) + { + _dateTimeOffsetAttr = value; + } + } + } + + /// + /// Backing field for DecimalAttr + /// + protected decimal? _decimalAttr; + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before setting. + /// + partial void SetDecimalAttr(decimal? oldValue, ref decimal? newValue); + /// + /// When provided in a partial class, allows value of DecimalAttr to be changed before returning. + /// + partial void GetDecimalAttr(ref decimal? result); + + public decimal? DecimalAttr + { + get + { + decimal? value = _decimalAttr; + GetDecimalAttr(ref value); + return (_decimalAttr = value); + } + set + { + decimal? oldValue = _decimalAttr; + SetDecimalAttr(oldValue, ref value); + if (oldValue != value) + { + _decimalAttr = value; + } + } + } + + /// + /// Backing field for DoubleAttr + /// + protected double? _doubleAttr; + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before setting. + /// + partial void SetDoubleAttr(double? oldValue, ref double? newValue); + /// + /// When provided in a partial class, allows value of DoubleAttr to be changed before returning. + /// + partial void GetDoubleAttr(ref double? result); + + public double? DoubleAttr + { + get + { + double? value = _doubleAttr; + GetDoubleAttr(ref value); + return (_doubleAttr = value); + } + set + { + double? oldValue = _doubleAttr; + SetDoubleAttr(oldValue, ref value); + if (oldValue != value) + { + _doubleAttr = value; + } + } + } + + /// + /// Backing field for GuidAttr + /// + protected Guid? _guidAttr; + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before setting. + /// + partial void SetGuidAttr(Guid? oldValue, ref Guid? newValue); + /// + /// When provided in a partial class, allows value of GuidAttr to be changed before returning. + /// + partial void GetGuidAttr(ref Guid? result); + + public Guid? GuidAttr + { + get + { + Guid? value = _guidAttr; + GetGuidAttr(ref value); + return (_guidAttr = value); + } + set + { + Guid? oldValue = _guidAttr; + SetGuidAttr(oldValue, ref value); + if (oldValue != value) + { + _guidAttr = value; + } + } + } + + /// + /// Backing field for Int16Attr + /// + protected short? _int16Attr; + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before setting. + /// + partial void SetInt16Attr(short? oldValue, ref short? newValue); + /// + /// When provided in a partial class, allows value of Int16Attr to be changed before returning. + /// + partial void GetInt16Attr(ref short? result); + + public short? Int16Attr + { + get + { + short? value = _int16Attr; + GetInt16Attr(ref value); + return (_int16Attr = value); + } + set + { + short? oldValue = _int16Attr; + SetInt16Attr(oldValue, ref value); + if (oldValue != value) + { + _int16Attr = value; + } + } + } + + /// + /// Backing field for Int32Attr + /// + protected int? _int32Attr; + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before setting. + /// + partial void SetInt32Attr(int? oldValue, ref int? newValue); + /// + /// When provided in a partial class, allows value of Int32Attr to be changed before returning. + /// + partial void GetInt32Attr(ref int? result); + + public int? Int32Attr + { + get + { + int? value = _int32Attr; + GetInt32Attr(ref value); + return (_int32Attr = value); + } + set + { + int? oldValue = _int32Attr; + SetInt32Attr(oldValue, ref value); + if (oldValue != value) + { + _int32Attr = value; + } + } + } + + /// + /// Backing field for Int64Attr + /// + protected long? _int64Attr; + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before setting. + /// + partial void SetInt64Attr(long? oldValue, ref long? newValue); + /// + /// When provided in a partial class, allows value of Int64Attr to be changed before returning. + /// + partial void GetInt64Attr(ref long? result); + + public long? Int64Attr + { + get + { + long? value = _int64Attr; + GetInt64Attr(ref value); + return (_int64Attr = value); + } + set + { + long? oldValue = _int64Attr; + SetInt64Attr(oldValue, ref value); + if (oldValue != value) + { + _int64Attr = value; + } + } + } + + /// + /// Backing field for SingleAttr + /// + protected Single? _singleAttr; + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before setting. + /// + partial void SetSingleAttr(Single? oldValue, ref Single? newValue); + /// + /// When provided in a partial class, allows value of SingleAttr to be changed before returning. + /// + partial void GetSingleAttr(ref Single? result); + + public Single? SingleAttr + { + get + { + Single? value = _singleAttr; + GetSingleAttr(ref value); + return (_singleAttr = value); + } + set + { + Single? oldValue = _singleAttr; + SetSingleAttr(oldValue, ref value); + if (oldValue != value) + { + _singleAttr = value; + } + } + } + + /// + /// Backing field for TimeAttr + /// + protected TimeSpan? _timeAttr; + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before setting. + /// + partial void SetTimeAttr(TimeSpan? oldValue, ref TimeSpan? newValue); + /// + /// When provided in a partial class, allows value of TimeAttr to be changed before returning. + /// + partial void GetTimeAttr(ref TimeSpan? result); + + public TimeSpan? TimeAttr + { + get + { + TimeSpan? value = _timeAttr; + GetTimeAttr(ref value); + return (_timeAttr = value); + } + set + { + TimeSpan? oldValue = _timeAttr; + SetTimeAttr(oldValue, ref value); + if (oldValue != value) + { + _timeAttr = value; + } + } + } + + /// + /// Backing field for StringAttr + /// + protected string _stringAttr; + /// + /// When provided in a partial class, allows value of StringAttr to be changed before setting. + /// + partial void SetStringAttr(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of StringAttr to be changed before returning. + /// + partial void GetStringAttr(ref string result); + + public string StringAttr + { + get + { + string value = _stringAttr; + GetStringAttr(ref value); + return (_stringAttr = value); + } + set + { + string oldValue = _stringAttr; + SetStringAttr(oldValue, ref value); + if (oldValue != value) + { + _stringAttr = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentRequired + { + partial void Init(); + + /// + /// Default constructor + /// + public UParentRequired() + { + UChildCollection = new System.Collections.Generic.HashSet(); + + Init(); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + /// + /// x + /// + [System.ComponentModel.Description("x")] + public partial class UParentOptional: global::Testing.HiddenEntity + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentOptional(): base() + { + PropertyInChild = "hello"; + UChildCollection = new System.Collections.Generic.HashSet(); + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentOptional CreateUParentOptionalUnsafe() + { + return new UParentOptional(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentOptional(global::Testing.UChild uchildrequired) + { + this.PropertyInChild = "hello"; + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + this.UChildCollection = new System.Collections.Generic.HashSet(); + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentOptional Create(global::Testing.UChild uchildrequired) + { + return new UParentOptional(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for PropertyInChild + /// + protected string _propertyInChild; + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before setting. + /// + partial void SetPropertyInChild(string oldValue, ref string newValue); + /// + /// When provided in a partial class, allows value of PropertyInChild to be changed before returning. + /// + partial void GetPropertyInChild(ref string result); + + /// + /// Default value = "hello" + /// + public string PropertyInChild + { + get + { + string value = _propertyInChild; + GetPropertyInChild(ref value); + return (_propertyInChild = value); + } + set + { + string oldValue = _propertyInChild; + SetPropertyInChild(oldValue, ref value); + if (oldValue != value) + { + _propertyInChild = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + /// + /// x + /// + [Description("x")] + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + /// + /// Backing field for UChildCollection + /// + protected ICollection _uChildCollection; + + /// + /// h + /// + [Description("h")] + public virtual ICollection UChildCollection + { + get + { + return _uChildCollection; + } + private set + { + _uChildCollection = value; + } + } + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UParentCollection + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UParentCollection() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UParentCollection CreateUParentCollectionUnsafe() + { + return new UParentCollection(); + } + + /// + /// Public constructor with required data + /// + /// + public UParentCollection(global::Testing.UChild uchildrequired) + { + if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); + this.UChildRequired = uchildrequired; + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static UParentCollection Create(global::Testing.UChild uchildrequired) + { + return new UParentCollection(uchildrequired); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Backing field for Id + /// + internal int _id; + /// + /// When provided in a partial class, allows value of Id to be changed before setting. + /// + partial void SetId(int oldValue, ref int newValue); + /// + /// When provided in a partial class, allows value of Id to be changed before returning. + /// + partial void GetId(ref int result); + + /// + /// Identity, Indexed, Required + /// + [Key] + [Required] + public int Id + { + get + { + int value = _id; + GetId(ref value); + return (_id = value); + } + set + { + int oldValue = _id; + SetId(oldValue, ref value); + if (oldValue != value) + { + _id = value; + } + } + } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Backing field for UChildRequired + /// + protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// + partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// + partial void GetUChildRequired(ref global::Testing.UChild result); + + /// + /// Required + /// + public virtual global::Testing.UChild UChildRequired + { + get + { + global::Testing.UChild value = _uChildRequired; + GetUChildRequired(ref value); + return (_uChildRequired = value); + } + set + { + global::Testing.UChild oldValue = _uChildRequired; + SetUChildRequired(oldValue, ref value); + if (oldValue != value) + { + _uChildRequired = value; + } + } + } + + /// + /// Backing field for UChildOptional + /// + protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// + partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// + partial void GetUChildOptional(ref global::Testing.UChild result); + + public virtual global::Testing.UChild UChildOptional + { + get + { + global::Testing.UChild value = _uChildOptional; + GetUChildOptional(ref value); + return (_uChildOptional = value); + } + set + { + global::Testing.UChild oldValue = _uChildOptional; + SetUChildOptional(oldValue, ref value); + if (oldValue != value) + { + _uChildOptional = value; + } + } + } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Testing +{ + public partial class UChild + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected UChild() + { + // NOTE: This class has one-to-one associations with UChild. + // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other. + + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static UChild CreateUChildUnsafe() + { + return new UChild(); + } + + /// + /// Public constructor with required data + /// diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/EFCore5ModelGenerator.ttinclude b/src/Testing/EFCoreV5/EFCore5NetCore3/EFCore5ModelGenerator.ttinclude deleted file mode 100644 index 1bce027a6..000000000 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/EFCore5ModelGenerator.ttinclude +++ /dev/null @@ -1,475 +0,0 @@ -<#@ include file="EF6ModelGenerator.ttinclude" once="true" -#><#@ include file="EFCore2ModelGenerator.ttinclude" once="true" -#><#@ include file="EFCore3ModelGenerator.ttinclude" once="true" -#><#@ include file="EFCore5ModelGenerator.ttinclude" once="true" -#><#@ include file="EFCoreModelGenerator.ttinclude" once="true" -#><#@ include file="EFModelFileManager.ttinclude" once="true" -#><#@ include file="EFModelGenerator.ttinclude" once="true" -#><#@ include file="VSIntegration.ttinclude" once="true" -#><#@ assembly name="System.Core" -#><#@ assembly name="System.Data.Linq" -#><#@ assembly name="EnvDTE" -#><#@ assembly name="System.Xml" -#><#@ assembly name="System.Xml.Linq" -#><#@ import namespace="System" -#><#@ import namespace="System.IO" -#><#@ import namespace="System.Globalization" -#><#@ import namespace="System.Linq" -#><#@ import namespace="System.Security" -#><#@ import namespace="System.Text" -#><#@ import namespace="System.Collections.Generic" -#><#@ import namespace="System.Diagnostics.CodeAnalysis" -#><#@ import namespace="EnvDTE" -#><#@ import namespace="System.Data.Entity.Design.PluralizationServices" -#><#@ import namespace="Microsoft.VisualStudio.TextTemplating" -#><#+ - // EFDesigner v3.0.0.5 - // Copyright (c) 2017-2020 Michael Sawczyn - // https://github.com/msawczyn/EFDesigner - - public class EFCore5ModelGenerator : EFCore3ModelGenerator - { - public EFCore5ModelGenerator(GeneratedTextTransformation host) : base(host) { } - - [SuppressMessage("ReSharper", "RedundantNameQualifier")] - protected override void ConfigureBidirectionalAssociations(ModelClass modelClass - , List visited - , List foreignKeyColumns - , List declaredShadowProperties) - { - MakeNonDependentAssociations(); - MakeDependentAssociations(modelClass, $"modelBuilder.Entity<{modelClass.FullName}>()"); - - void MakeNonDependentAssociations() - { - // ReSharper disable once LoopCanBePartlyConvertedToQuery - foreach (BidirectionalAssociation association in Association.GetLinksToTargets(modelClass) - .OfType() - .Where(x => x.Persistent && !x.Target.IsDependentType)) - { - if (visited.Contains(association)) - continue; - - visited.Add(association); - - List segments = new List(); - bool sourceRequired = false; - bool targetRequired = false; - - segments.Add($"modelBuilder.Entity<{modelClass.FullName}>()"); - - switch (association.TargetMultiplicity) // realized by property on source - { - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroMany: - { - segments.Add($"HasMany<{association.Target.FullName}>(p => p.{association.TargetPropertyName})"); - - break; - } - - case Sawczyn.EFDesigner.EFModel.Multiplicity.One: - { - segments.Add($"HasOne<{association.Target.FullName}>(p => p.{association.TargetPropertyName})"); - targetRequired = true; - - break; - } - - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroOne: - { - segments.Add($"HasOne<{association.Target.FullName}>(p => p.{association.TargetPropertyName})"); - - break; - } - } - - switch (association.SourceMultiplicity) // realized by property on target, but no property on target - { - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroMany: - { - segments.Add($"WithMany(p => p.{association.SourcePropertyName})"); - - if (association.TargetMultiplicity == Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroMany) - { - string tableMap = string.IsNullOrEmpty(association.JoinTableName) - ? $"{association.Target.Name}_{association.SourcePropertyName}_x_{association.Source.Name}_{association.TargetPropertyName}" - : association.JoinTableName; - - segments.Add($"UsingEntity(x => x.ToTable(\"{tableMap}\"))"); - } - - break; - } - - case Sawczyn.EFDesigner.EFModel.Multiplicity.One: - { - segments.Add($"WithOne(p => p.{association.SourcePropertyName})"); - sourceRequired = true; - - break; - } - - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroOne: - segments.Add($"WithOne(p => p.{association.SourcePropertyName})"); - - break; - } - - string foreignKeySegment = CreateForeignKeySegment(association, foreignKeyColumns); - - if (!string.IsNullOrEmpty(foreignKeySegment)) - segments.Add(foreignKeySegment); - - Output(segments); - - if (!association.TargetAutoProperty) - { - segments.Add($"modelBuilder.Entity<{association.Source.FullName}>().Navigation(e => e.{association.TargetPropertyName})"); - segments.Add($"HasField(\"{association.TargetBackingFieldName}\")"); - segments.Add($"UsePropertyAccessMode(PropertyAccessMode.{association.TargetPropertyAccessMode})"); - Output(segments); - } - - if (!association.SourceAutoProperty) - { - segments.Add($"modelBuilder.Entity<{association.Target.FullName}>().Navigation(e => e.{association.SourcePropertyName})"); - segments.Add($"HasField(\"{association.SourceBackingFieldName}\")"); - segments.Add($"UsePropertyAccessMode(PropertyAccessMode.{association.SourcePropertyAccessMode})"); - Output(segments); - } - - if (targetRequired) - Output($"modelBuilder.Entity<{association.Source.FullName}>().Navigation(e => e.{association.TargetPropertyName}).IsRequired();"); - - if (sourceRequired) - Output($"modelBuilder.Entity<{association.Target.FullName}>().Navigation(e => e.{association.SourcePropertyName}).IsRequired();"); - - if (association.TargetDeleteAction == DeleteAction.None) - Output($"modelBuilder.Entity<{association.Source.FullName}>().Navigation(e => e.{association.TargetPropertyName}).OnDelete(DeleteBehavior.NoAction);"); - else if (association.TargetDeleteAction == DeleteAction.Cascade) - Output($"modelBuilder.Entity<{association.Source.FullName}>().Navigation(e => e.{association.TargetPropertyName}).OnDelete(DeleteBehavior.Cascade);"); - - if (association.SourceDeleteAction == DeleteAction.None) - Output($"modelBuilder.Entity<{association.Target.FullName}>().Navigation(e => e.{association.SourcePropertyName}).OnDelete(DeleteBehavior.NoAction);"); - else if (association.SourceDeleteAction == DeleteAction.Cascade) - Output($"modelBuilder.Entity<{association.Target.FullName}>().Navigation(e => e.{association.SourcePropertyName}).OnDelete(DeleteBehavior.Cascade);"); - } - } - - void MakeDependentAssociations(ModelClass sourceInstance, string baseSegment) - { - // ReSharper disable once LoopCanBePartlyConvertedToQuery - foreach (BidirectionalAssociation association in Association.GetLinksToTargets(sourceInstance) - .OfType() - .Where(x => x.Persistent && x.Target.IsDependentType)) - { - if (visited.Contains(association)) - continue; - - visited.Add(association); - - List segments = new List(); - - switch (association.TargetMultiplicity) // realized by property on source - { - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroMany: - { - segments.Add(baseSegment); - segments.Add($"OwnsMany(p => p.{association.TargetPropertyName})"); - segments.Add($"ToTable(\"{(string.IsNullOrEmpty(association.Target.TableName) ? association.Target.Name : association.Target.TableName)}\")"); - Output(segments); - - segments.Add(baseSegment); - segments.Add($"OwnsMany(p => p.{association.TargetPropertyName})"); - segments.Add($"WithOwner(\"{association.SourcePropertyName}\")"); - segments.Add($"HasForeignKey(\"{association.SourcePropertyName}Id\")"); - Output(segments); - - segments.Add(baseSegment); - segments.Add($"OwnsMany(p => p.{association.TargetPropertyName})"); - segments.Add("Property(\"Id\")"); - - Output(segments); - - segments.Add(baseSegment); - segments.Add($"OwnsMany(p => p.{association.TargetPropertyName})"); - segments.Add("HasKey(\"Id\")"); - - Output(segments); - - MakeDependentAssociations(association.Target, $"{baseSegment}.OwnsMany(p => p.{association.TargetPropertyName})"); - - break; - } - - case Sawczyn.EFDesigner.EFModel.Multiplicity.One: - { - segments.Add(baseSegment); - segments.Add($"OwnsOne(p => p.{association.TargetPropertyName})"); - segments.Add($"WithOwner(p => p.{association.SourcePropertyName})"); - Output(segments); - - if (!string.IsNullOrEmpty(association.Target.TableName)) - { - segments.Add(baseSegment); - segments.Add($"OwnsOne(p => p.{association.TargetPropertyName})"); - segments.Add($"ToTable(\"{association.Target.TableName}\")"); - Output(segments); - } - - foreach (ModelAttribute modelAttribute in association.Target.AllAttributes) - { - segments.Add($"{baseSegment}.OwnsOne(p => p.{association.TargetPropertyName}).Property(p => p.{modelAttribute.Name})"); - - if (modelAttribute.ColumnName != modelAttribute.Name && !string.IsNullOrEmpty(modelAttribute.ColumnName)) - segments.Add($"HasColumnName(\"{modelAttribute.ColumnName}\")"); - - if (modelAttribute.Required) - segments.Add("IsRequired()"); - - if (segments.Count > 1) - Output(segments); - - segments.Clear(); - } - - segments.Add(baseSegment); - segments.Add($"Navigation(p => p.{association.TargetPropertyName}).IsRequired()"); - Output(segments); - - MakeDependentAssociations(association.Target, $"{baseSegment}.OwnsOne(p => p.{association.TargetPropertyName})"); - - break; - } - - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroOne: - { - segments.Add(baseSegment); - segments.Add($"OwnsOne(p => p.{association.TargetPropertyName})"); - segments.Add($"WithOwner(p => p.{association.SourcePropertyName})"); - Output(segments); - - if (!string.IsNullOrEmpty(association.Target.TableName)) - { - segments.Add(baseSegment); - segments.Add($"OwnsOne(p => p.{association.TargetPropertyName})"); - segments.Add($"ToTable(\"{association.Target.TableName}\")"); - Output(segments); - } - - foreach (ModelAttribute modelAttribute in association.Target.AllAttributes) - { - segments.Add($"{baseSegment}.OwnsOne(p => p.{association.TargetPropertyName}).Property(p => p.{modelAttribute.Name})"); - - if (modelAttribute.ColumnName != modelAttribute.Name && !string.IsNullOrEmpty(modelAttribute.ColumnName)) - segments.Add($"HasColumnName(\"{modelAttribute.ColumnName}\")"); - - if (modelAttribute.Required) - segments.Add("IsRequired()"); - - if (segments.Count > 1) - Output(segments); - - segments.Clear(); - } - - MakeDependentAssociations(association.Target, $"{baseSegment}.OwnsOne(p => p.{association.TargetPropertyName})"); - - break; - } - } - } - } - } - - [SuppressMessage("ReSharper", "RedundantNameQualifier")] - protected override void ConfigureUnidirectionalAssociations(ModelClass modelClass - , List visited - , List foreignKeyColumns - , List declaredShadowProperties) - { - MakeNonDependentAssociations(); - MakeDependentAssociations(modelClass, $"modelBuilder.Entity<{modelClass.FullName}>()"); - - void MakeNonDependentAssociations() - { - // ReSharper disable once LoopCanBePartlyConvertedToQuery - foreach (UnidirectionalAssociation association in Association.GetLinksToTargets(modelClass) - .OfType() - .Where(x => x.Persistent && !x.Target.IsDependentType)) - { - if (visited.Contains(association)) - continue; - - visited.Add(association); - - List segments = new List(); - bool sourceRequired = false; - bool targetRequired = false; - - segments.Add($"modelBuilder.Entity<{modelClass.FullName}>()"); - - switch (association.TargetMultiplicity) // realized by property on source - { - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroMany: - segments.Add($"HasMany<{association.Target.FullName}>(p => p.{association.TargetPropertyName})"); - - break; - - case Sawczyn.EFDesigner.EFModel.Multiplicity.One: - segments.Add($"HasOne<{association.Target.FullName}>(p => p.{association.TargetPropertyName})"); - targetRequired = true; - - break; - - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroOne: - segments.Add($"HasOne<{association.Target.FullName}>(p => p.{association.TargetPropertyName})"); - - break; - } - - switch (association.SourceMultiplicity) // realized by property on target, but no property on target - { - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroMany: - segments.Add("WithMany()"); - - if (association.TargetMultiplicity == Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroMany) - { - string tableMap = string.IsNullOrEmpty(association.JoinTableName) - ? $"{association.Target.Name}_x_{association.Source.Name}_{association.TargetPropertyName}" - : association.JoinTableName; - - segments.Add($"UsingEntity(x => x.ToTable(\"{tableMap}\"))"); - } - - break; - - case Sawczyn.EFDesigner.EFModel.Multiplicity.One: - segments.Add("WithOne()"); - sourceRequired = true; - - break; - - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroOne: - segments.Add("WithOne()"); - - break; - } - - string foreignKeySegment = CreateForeignKeySegment(association, foreignKeyColumns); - - if (!string.IsNullOrEmpty(foreignKeySegment)) - segments.Add(foreignKeySegment); - - if (sourceRequired || targetRequired) - segments.Add("IsRequired()"); - - if (association.TargetDeleteAction == DeleteAction.None || association.SourceDeleteAction == DeleteAction.None) - segments.Add("OnDelete(DeleteBehavior.NoAction);"); - if (association.TargetDeleteAction == DeleteAction.Cascade || association.SourceDeleteAction == DeleteAction.Cascade) - segments.Add("OnDelete(DeleteBehavior.Cascade);"); - - Output(segments); - - if (!association.TargetAutoProperty) - { - segments.Add($"modelBuilder.Entity<{association.Source.FullName}>().Navigation(e => e.{association.TargetPropertyName})"); - segments.Add($"HasField(\"{association.TargetBackingFieldName}\")"); - segments.Add($"UsePropertyAccessMode(PropertyAccessMode.{association.TargetPropertyAccessMode})"); - Output(segments); - } - } - } - - void MakeDependentAssociations(ModelClass sourceInstance, string baseSegment) - { - // ReSharper disable once LoopCanBePartlyConvertedToQuery - foreach (UnidirectionalAssociation association in Association.GetLinksToTargets(sourceInstance) - .OfType() - .Where(x => x.Persistent && x.Target.IsDependentType)) - { - if (visited.Contains(association)) - continue; - - visited.Add(association); - - List segments = new List(); - - switch (association.TargetMultiplicity) // realized by property on source - { - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroMany: - { - segments.Add(baseSegment); - segments.Add($"OwnsMany(p => p.{association.TargetPropertyName})"); - segments.Add($"WithOwner(\"{association.Source.Name}_{association.TargetPropertyName}\")"); - segments.Add($"HasForeignKey(\"{association.Source.Name}_{association.TargetPropertyName}Id\")"); - Output(segments); - - segments.Add(baseSegment); - segments.Add($"OwnsMany(p => p.{association.TargetPropertyName})"); - segments.Add("Property(\"Id\")"); - - Output(segments); - - segments.Add(baseSegment); - segments.Add($"OwnsMany(p => p.{association.TargetPropertyName})"); - segments.Add("HasKey(\"Id\")"); - - Output(segments); - - MakeDependentAssociations(association.Target, $"{baseSegment}.OwnsMany(p => p.{association.TargetPropertyName})"); - - break; - } - - case Sawczyn.EFDesigner.EFModel.Multiplicity.One: - { - foreach (ModelAttribute modelAttribute in association.Target.AllAttributes) - { - segments.Add($"{baseSegment}.OwnsOne(p => p.{association.TargetPropertyName}).Property(p => p.{modelAttribute.Name})"); - - if (modelAttribute.ColumnName != modelAttribute.Name && !string.IsNullOrEmpty(modelAttribute.ColumnName)) - segments.Add($"HasColumnName(\"{modelAttribute.ColumnName}\")"); - - if (modelAttribute.Required) - segments.Add("IsRequired()"); - - Output(segments); - } - - segments.Add(baseSegment); - segments.Add($"Navigation(p => p.{association.TargetPropertyName}).IsRequired()"); - Output(segments); - - MakeDependentAssociations(association.Target, $"{baseSegment}.OwnsOne(p => p.{association.TargetPropertyName})"); - - break; - } - - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroOne: - { - foreach (ModelAttribute modelAttribute in association.Target.AllAttributes) - { - segments.Add($"{baseSegment}.OwnsOne(p => p.{association.TargetPropertyName}).Property(p => p.{modelAttribute.Name})"); - - if (modelAttribute.ColumnName != modelAttribute.Name && !string.IsNullOrEmpty(modelAttribute.ColumnName)) - segments.Add($"HasColumnName(\"{modelAttribute.ColumnName}\")"); - - if (modelAttribute.Required) - segments.Add("IsRequired()"); - - Output(segments); - } - - MakeDependentAssociations(association.Target, $"{baseSegment}.OwnsOne(p => p.{association.TargetPropertyName})"); - - break; - } - } - } - } - } - } - - -#> diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Context/AllFeatureModel.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Context/AllFeatureModel.generated.cs index e1fed67fb..a86aa5ede 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Context/AllFeatureModel.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Context/AllFeatureModel.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -68,6 +68,8 @@ public AllFeatureModel(DbContextOptions options) : base(options /// protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { + optionsBuilder.UseLazyLoadingProxies(); + CustomInit(optionsBuilder); } @@ -82,10 +84,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.HasDefaultSchema("dbo"); - modelBuilder.Entity().ToTable("AbstractBaseClasses").HasKey(t => t.Id); + modelBuilder.Entity().ToTable("AbstractBaseClasses"); modelBuilder.Entity().ToTable("AllPropertyTypesOptionals").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever().IsRequired(); modelBuilder.Entity().Property(t => t.BinaryAttr).HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.BooleanAttr).HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.ByteAttr).HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); @@ -102,92 +104,81 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.StringAttr).HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("AllPropertyTypesRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever(); - modelBuilder.Entity().Property(t => t.BinaryAttr).IsRequired().HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.BooleanAttr).IsRequired().HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.ByteAttr).IsRequired().HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DateTimeAttr).IsRequired().HasField("_dateTimeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DateTimeOffsetAttr).IsRequired().HasField("_dateTimeOffsetAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DecimalAttr).IsRequired().HasField("_decimalAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.DoubleAttr).IsRequired().HasField("_doubleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.GuidAttr).IsRequired().HasField("_guidAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int16Attr).IsRequired().HasField("_int16Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int32Attr).IsRequired().HasField("_int32Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.Int64Attr).IsRequired().HasField("_int64Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.SingleAttr).IsRequired().HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.TimeAttr).IsRequired().HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Property(t => t.StringAttr).IsRequired().HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - - modelBuilder.Entity().ToTable("BaseClasses").HasKey(t => t.Id); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever().IsRequired(); + modelBuilder.Entity().Property(t => t.BinaryAttr).HasField("_binaryAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.BooleanAttr).HasField("_booleanAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.ByteAttr).HasField("_byteAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DateTimeAttr).HasField("_dateTimeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DateTimeOffsetAttr).HasField("_dateTimeOffsetAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DecimalAttr).HasField("_decimalAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.DoubleAttr).HasField("_doubleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.GuidAttr).HasField("_guidAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int16Attr).HasField("_int16Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int32Attr).HasField("_int32Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.Int64Attr).HasField("_int64Attr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.SingleAttr).HasField("_singleAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.TimeAttr).HasField("_timeAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + modelBuilder.Entity().Property(t => t.StringAttr).HasField("_stringAttr").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); + + modelBuilder.Entity().ToTable("BaseClasses"); modelBuilder.Entity().ToTable("BaseClassWithRequiredProperties").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().Property(t => t.Property0).IsRequired().HasField("_property0").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().Property(t => t.Property0).HasField("_property0").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().ToTable("BChilds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("BParentCollections").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithMany(p => p.BParentCollection).HasForeignKey("BChildRequiredId"); - modelBuilder.Entity().Navigation(e => e.BChildRequired).HasField("_bChildRequired").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Navigation(e => e.BChildRequired).IsRequired(); modelBuilder.Entity().HasMany(p => p.BChildCollection).WithMany(p => p.BParentCollection_1).UsingEntity(x => x.ToTable("BChild_BParentCollection_1_x_BParentCollection_BChildCollection")); - modelBuilder.Entity().Navigation(e => e.BChildCollection).HasField("_bChildCollection").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithMany(p => p.BParentCollection_2).HasForeignKey("BChildOptionalId"); - modelBuilder.Entity().Navigation(e => e.BChildOptional).HasField("_bChildOptional").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("BParentOptionals").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentOptional).HasForeignKey("BParentOptional", "BChildRequiredId"); - modelBuilder.Entity().Navigation(e => e.BChildRequired).HasField("_bChildRequired").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Navigation(e => e.BChildRequired).IsRequired(); modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentOptional_1).HasForeignKey("BParentOptional_1Id"); - modelBuilder.Entity().Navigation(e => e.BChildCollection).HasField("_bChildCollection").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentOptional_2).HasForeignKey("BChild", "BParentOptional_2Id"); - modelBuilder.Entity().Navigation(e => e.BChildOptional).HasField("_bChildOptional").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("BParentRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasOne(p => p.BChildOptional).WithOne(p => p.BParentRequired).HasForeignKey("BChild", "BParentRequiredId"); - modelBuilder.Entity().Navigation(e => e.BChildOptional).HasField("_bChildOptional").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Navigation(e => e.BParentRequired).IsRequired(); - modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentRequired_1).HasForeignKey("BChild", "BParentRequired_1Id"); - modelBuilder.Entity().Navigation(e => e.BChildRequired).HasField("_bChildRequired").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().Navigation(e => e.BChildRequired).IsRequired(); + modelBuilder.Entity().HasOne(p => p.BChildRequired).WithOne(p => p.BParentRequired_1).HasForeignKey("BChild", "BParentRequired_1Id").IsRequired(); modelBuilder.Entity().Navigation(e => e.BParentRequired_1).IsRequired(); modelBuilder.Entity().HasMany(p => p.BChildCollection).WithOne(p => p.BParentRequired_2).HasForeignKey("BParentRequired_2Id"); - modelBuilder.Entity().Navigation(e => e.BChildCollection).HasField("_bChildCollection").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Navigation(e => e.BParentRequired_2).IsRequired(); modelBuilder.Entity().ToTable("Children").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().HasMany(p => p.Children).WithOne(p => p.Parent).HasForeignKey("ParentId"); - modelBuilder.Entity().Navigation(e => e.Children).HasField("_children").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Navigation(e => e.Parent).IsRequired(); - modelBuilder.Entity().ToTable("ConcreteDerivedClasses").HasKey(t => t.Id); + modelBuilder.Entity().ToTable("ConcreteDerivedClasses"); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().ToTable("ConcreteDerivedClassWithRequiredProperties").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Property1).IsRequired().HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().ToTable("ConcreteDerivedClassWithRequiredProperties"); + modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); - modelBuilder.Entity().ToTable("DerivedClasses").HasKey(t => t.Id); + modelBuilder.Entity().ToTable("DerivedClasses"); modelBuilder.Entity().Property(t => t.Property1).HasField("_property1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("HiddenEntities").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("Masters").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasMany(p => p.Children).WithOne().HasForeignKey("Master_Children_Id").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasMany(p => p.Children).WithOne().HasForeignKey("MasterChildrenId"); modelBuilder.Entity().Navigation(e => e.Children).HasField("_children").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("ParserTests").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever(); - modelBuilder.Entity().Property(t => t.foo).IsRequired().HasField("_foo").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedNever().IsRequired(); + modelBuilder.Entity().Property(t => t.foo).HasField("_foo").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).IsRequired(); modelBuilder.Entity().Property(t => t.name1).HasField("_name1").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.name2).HasField("_name2").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().Property(t => t.name3).HasField("_name3").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); @@ -208,34 +199,36 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.name18).HasField("_name18").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("RenamedColumns").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasColumnName("Foo").HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasColumnName("Foo").HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("UChilds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().ToTable("UParentCollections").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasOne(p => p.UChildRequired).WithMany().HasForeignKey("UChildRequiredId").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasOne(p => p.UChildRequired).WithMany().HasForeignKey("UChildRequiredId"); + modelBuilder.Entity().Navigation(e => e.UChildRequired).IsRequired(); modelBuilder.Entity().Navigation(e => e.UChildRequired).HasField("_uChildRequired").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().HasOne(p => p.UChildOptional).WithMany().HasForeignKey("UChildOptionalId"); modelBuilder.Entity().Navigation(e => e.UChildOptional).HasField("_uChildOptional").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().ToTable("UParentOptionals").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentOptional_UChildOptional_Id"); + modelBuilder.Entity().ToTable("UParentOptionals"); + modelBuilder.Entity().Property(t => t.PropertyInChild).HasField("_propertyInChild").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).HasDefaultValue("hello"); + modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentOptionalUChildOptionalId"); modelBuilder.Entity().Navigation(e => e.UChildOptional).HasField("_uChildOptional").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentOptional_UChildCollection_Id"); + modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentOptionalUChildCollectionId"); modelBuilder.Entity().Navigation(e => e.UChildCollection).HasField("_uChildCollection").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UParentOptional", "UChildRequiredId").IsRequired(); + modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UParentOptional", "UChildRequiredId"); + modelBuilder.Entity().Navigation(e => e.UChildRequired).IsRequired(); modelBuilder.Entity().Navigation(e => e.UChildRequired).HasField("_uChildRequired").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); modelBuilder.Entity().ToTable("UParentRequireds").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd(); - modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UChild", "UParentRequired_UChildRequired_Id").IsRequired(); + modelBuilder.Entity().Property(t => t.Id).HasField("_id").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasOne(p => p.UChildRequired).WithOne().HasForeignKey("UChild", "UParentRequiredUChildRequiredId").IsRequired(); modelBuilder.Entity().Navigation(e => e.UChildRequired).HasField("_uChildRequired").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentRequired_UChildCollection_Id").IsRequired(); + modelBuilder.Entity().HasMany(p => p.UChildCollection).WithOne().HasForeignKey("UParentRequiredUChildCollectionId"); modelBuilder.Entity().Navigation(e => e.UChildCollection).HasField("_uChildCollection").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); - modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentRequired_UChildOptional_Id").IsRequired().OnDelete(DeleteBehavior.Cascade);; + modelBuilder.Entity().HasOne(p => p.UChildOptional).WithOne().HasForeignKey("UChild", "UParentRequiredUChildOptionalId").OnDelete(DeleteBehavior.Cascade); modelBuilder.Entity().Navigation(e => e.UChildOptional).HasField("_uChildOptional").UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction); OnModelCreatedImpl(modelBuilder); diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/AbstractBaseClass.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/AbstractBaseClass.generated.cs index b3ccbcc04..cd345aed9 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/AbstractBaseClass.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/AbstractBaseClass.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -45,7 +45,6 @@ protected AbstractBaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/AllPropertyTypesOptional.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/AllPropertyTypesOptional.generated.cs index 39f3fd628..28649cbed 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/AllPropertyTypesOptional.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/AllPropertyTypesOptional.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -66,7 +66,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/AllPropertyTypesRequired.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/AllPropertyTypesRequired.generated.cs index 4e46193a2..3f280e479 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/AllPropertyTypesRequired.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/AllPropertyTypesRequired.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -92,7 +92,6 @@ public AllPropertyTypesRequired(byte[] binaryattr, bool booleanattr, byte byteat if (string.IsNullOrEmpty(stringattr)) throw new ArgumentNullException(nameof(stringattr)); this.StringAttr = stringattr; - Init(); } @@ -148,7 +147,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BChild.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BChild.generated.cs index 356bc15b8..633937ed0 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BChild.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BChild.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -39,12 +39,6 @@ protected BChild() BParentCollection = new System.Collections.Generic.HashSet(); BParentCollection_1 = new System.Collections.Generic.HashSet(); BParentCollection_2 = new System.Collections.Generic.HashSet(); - BParentRequired = new global::Testing.BParentRequired(); - BParentRequired_1 = new global::Testing.BParentRequired(); - BParentRequired_2 = new global::Testing.BParentRequired(); - BParentOptional = global::Testing.BParentOptional.CreateBParentOptionalUnsafe(); - BParentOptional_1 = global::Testing.BParentOptional.CreateBParentOptionalUnsafe(); - BParentOptional_2 = global::Testing.BParentOptional.CreateBParentOptionalUnsafe(); Init(); } @@ -69,14 +63,15 @@ public BChild(global::Testing.BParentRequired bparentrequired, global::Testing.B if (bparentrequired == null) throw new ArgumentNullException(nameof(bparentrequired)); this.BParentRequired = bparentrequired; + bparentrequired.BChildOptional = this; if (bparentrequired_2 == null) throw new ArgumentNullException(nameof(bparentrequired_2)); this.BParentRequired_2 = bparentrequired_2; + bparentrequired_2.BChildCollection.Add(this); this.BParentCollection = new System.Collections.Generic.HashSet(); this.BParentCollection_1 = new System.Collections.Generic.HashSet(); this.BParentCollection_2 = new System.Collections.Generic.HashSet(); - Init(); } @@ -120,7 +115,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BParentCollection.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BParentCollection.generated.cs index 5d29ffb16..36b75de8a 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BParentCollection.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BParentCollection.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -34,8 +34,6 @@ public partial class BParentCollection protected BParentCollection() { BChildCollection = new System.Collections.Generic.HashSet(); - BChildRequired = global::Testing.BChild.CreateBChildUnsafe(); - BChildOptional = global::Testing.BChild.CreateBChildUnsafe(); Init(); } @@ -56,9 +54,9 @@ public BParentCollection(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; + bchildrequired.BParentCollection.Add(this); this.BChildCollection = new System.Collections.Generic.HashSet(); - Init(); } @@ -101,7 +99,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -116,8 +114,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -142,7 +151,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get @@ -155,8 +168,19 @@ private set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BParentOptional.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BParentOptional.generated.cs index 9a4b777c0..aa00e07a8 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BParentOptional.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BParentOptional.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -34,8 +34,6 @@ public partial class BParentOptional protected BParentOptional() { BChildCollection = new System.Collections.Generic.HashSet(); - BChildRequired = global::Testing.BChild.CreateBChildUnsafe(); - BChildOptional = global::Testing.BChild.CreateBChildUnsafe(); Init(); } @@ -56,9 +54,9 @@ public BParentOptional(global::Testing.BChild bchildrequired) { if (bchildrequired == null) throw new ArgumentNullException(nameof(bchildrequired)); this.BChildRequired = bchildrequired; + bchildrequired.BParentOptional = this; this.BChildCollection = new System.Collections.Generic.HashSet(); - Init(); } @@ -101,7 +99,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -116,8 +114,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -142,7 +151,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get @@ -155,8 +168,19 @@ private set } } + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BParentRequired.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BParentRequired.generated.cs index 7d8815e6d..aa8d4efb8 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BParentRequired.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BParentRequired.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -34,8 +34,6 @@ public partial class BParentRequired public BParentRequired() { BChildCollection = new System.Collections.Generic.HashSet(); - BChildOptional = global::Testing.BChild.CreateBChildUnsafe(); - BChildRequired = global::Testing.BChild.CreateBChildUnsafe(); Init(); } @@ -70,7 +68,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -85,8 +83,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for BChildOptional + /// protected global::Testing.BChild _bChildOptional; + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before setting. + /// partial void SetBChildOptional(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildOptional to be changed before returning. + /// partial void GetBChildOptional(ref global::Testing.BChild result); public virtual global::Testing.BChild BChildOptional @@ -108,8 +117,19 @@ protected set } } + /// + /// Backing field for BChildRequired + /// protected global::Testing.BChild _bChildRequired; + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before setting. + /// partial void SetBChildRequired(global::Testing.BChild oldValue, ref global::Testing.BChild newValue); + + /// + /// When provided in a partial class, allows value of BChildRequired to be changed before returning. + /// partial void GetBChildRequired(ref global::Testing.BChild result); /// @@ -134,7 +154,11 @@ protected set } } + /// + /// Backing field for BChildCollection + /// protected ICollection _bChildCollection; + public virtual ICollection BChildCollection { get diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BaseClass.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BaseClass.generated.cs index 7f5641e51..158315590 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BaseClass.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BaseClass.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -53,7 +53,6 @@ public BaseClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BaseClassWithRequiredProperties.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BaseClassWithRequiredProperties.generated.cs index 6e5d5ba15..93a2ef75f 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BaseClassWithRequiredProperties.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/BaseClassWithRequiredProperties.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -53,7 +53,6 @@ public BaseClassWithRequiredProperties(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } @@ -96,7 +95,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/Child.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/Child.generated.cs index f64a9635e..aeb450e80 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/Child.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/Child.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -34,7 +34,6 @@ public partial class Child protected Child() { Children = new System.Collections.Generic.HashSet(); - Parent = global::Testing.Child.CreateChildUnsafe(); Init(); } @@ -56,12 +55,12 @@ public Child(global::Testing.Child parent, global::Testing.Master _master0) { if (parent == null) throw new ArgumentNullException(nameof(parent)); this.Parent = parent; + parent.Children.Add(this); if (_master0 == null) throw new ArgumentNullException(nameof(_master0)); _master0.Children.Add(this); this.Children = new System.Collections.Generic.HashSet(); - Init(); } @@ -105,7 +104,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -120,7 +119,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/ConcreteDerivedClass.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/ConcreteDerivedClass.generated.cs index 50be1530c..9f94a2102 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/ConcreteDerivedClass.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/ConcreteDerivedClass.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -53,7 +53,6 @@ public ConcreteDerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs index bffc9db81..5e1dc7dc9 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/ConcreteDerivedClassWithRequiredProperties.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -57,7 +57,6 @@ public ConcreteDerivedClassWithRequiredProperties(string property1, string prope if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/DerivedClass.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/DerivedClass.generated.cs index c6c2098c6..1afc9184a 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/DerivedClass.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/DerivedClass.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -53,7 +53,6 @@ public DerivedClass(string property0) if (string.IsNullOrEmpty(property0)) throw new ArgumentNullException(nameof(property0)); this.Property0 = property0; - Init(); } diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/HiddenEntity.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/HiddenEntity.generated.cs index ef046c7c1..d77ec772d 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/HiddenEntity.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/HiddenEntity.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -66,7 +66,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/Master.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/Master.generated.cs index 721b89a02..f47dc6eaa 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/Master.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/Master.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -68,7 +68,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -83,7 +83,11 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for Children + /// protected ICollection _children; + public virtual ICollection Children { get diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/ParserTest.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/ParserTest.generated.cs index a1ad32f84..8852ab432 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/ParserTest.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/ParserTest.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -52,7 +52,6 @@ public ParserTest(long foo) { this.foo = foo; - Init(); } @@ -95,7 +94,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/RenamedColumn.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/RenamedColumn.generated.cs index 90b64d2f7..0ca375673 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/RenamedColumn.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/RenamedColumn.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -66,7 +66,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/UChild.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/UChild.generated.cs index b583c52bd..184746d13 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/UChild.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/UChild.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -63,7 +63,6 @@ public UChild(global::Testing.UParentRequired _uparentrequired1, global::Testing if (_uparentrequired2 == null) throw new ArgumentNullException(nameof(_uparentrequired2)); _uparentrequired2.UChildOptional = this; - Init(); } @@ -107,7 +106,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/UParentCollection.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/UParentCollection.generated.cs index 80df7c6cc..fc0dfd2ad 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/UParentCollection.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/UParentCollection.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -33,9 +33,6 @@ public partial class UParentCollection /// protected UParentCollection() { - UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); - UChildOptional = global::Testing.UChild.CreateUChildUnsafe(); - Init(); } @@ -56,7 +53,6 @@ public UParentCollection(global::Testing.UChild uchildrequired) if (uchildrequired == null) throw new ArgumentNullException(nameof(uchildrequired)); this.UChildRequired = uchildrequired; - Init(); } @@ -99,7 +95,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -114,8 +110,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -140,8 +147,19 @@ protected set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/UParentOptional.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/UParentOptional.generated.cs index 486aabb96..878bbe039 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/UParentOptional.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/UParentOptional.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -27,7 +27,8 @@ namespace Testing /// /// x /// - public partial class UParentOptional: global::Testing.HiddenEntity, INotifyPropertyChanged + [System.ComponentModel.Description("x")] + public partial class UParentOptional: global::Testing.HiddenEntity { partial void Init(); @@ -38,8 +39,6 @@ protected UParentOptional(): base() { PropertyInChild = "hello"; UChildCollection = new System.Collections.Generic.HashSet(); - UChildOptional = global::Testing.UChild.CreateUChildUnsafe(); - UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); Init(); } @@ -63,7 +62,6 @@ public UParentOptional(global::Testing.UChild uchildrequired) this.UChildRequired = uchildrequired; this.UChildCollection = new System.Collections.Generic.HashSet(); - Init(); } @@ -119,13 +117,25 @@ public string PropertyInChild * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); /// /// x /// + [Description("x")] public virtual global::Testing.UChild UChildOptional { get @@ -145,10 +155,15 @@ public string PropertyInChild } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + /// /// h /// + [Description("h")] public virtual ICollection UChildCollection { get @@ -161,8 +176,19 @@ private set } } + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -187,13 +213,6 @@ private set } } - public virtual event PropertyChangedEventHandler PropertyChanged; - - protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } - } } diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/UParentRequired.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/UParentRequired.generated.cs index 103e8522a..20d35c624 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/UParentRequired.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Entities/UParentRequired.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -34,8 +34,6 @@ public partial class UParentRequired public UParentRequired() { UChildCollection = new System.Collections.Generic.HashSet(); - UChildRequired = global::Testing.UChild.CreateUChildUnsafe(); - UChildOptional = global::Testing.UChild.CreateUChildUnsafe(); Init(); } @@ -70,7 +68,7 @@ public int Id GetId(ref value); return (_id = value); } - protected set + set { int oldValue = _id; SetId(oldValue, ref value); @@ -85,8 +83,19 @@ protected set * Navigation properties *************************************************************************/ + /// + /// Backing field for UChildRequired + /// protected global::Testing.UChild _uChildRequired; + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before setting. + /// partial void SetUChildRequired(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildRequired to be changed before returning. + /// partial void GetUChildRequired(ref global::Testing.UChild result); /// @@ -111,7 +120,11 @@ protected set } } + /// + /// Backing field for UChildCollection + /// protected ICollection _uChildCollection; + public virtual ICollection UChildCollection { get @@ -124,8 +137,19 @@ private set } } + /// + /// Backing field for UChildOptional + /// protected global::Testing.UChild _uChildOptional; + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before setting. + /// partial void SetUChildOptional(global::Testing.UChild oldValue, ref global::Testing.UChild newValue); + + /// + /// When provided in a partial class, allows value of UChildOptional to be changed before returning. + /// partial void GetUChildOptional(ref global::Testing.UChild result); public virtual global::Testing.UChild UChildOptional diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Enums/Enum1.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Enums/Enum1.generated.cs index dfa839238..7709980bd 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Enums/Enum1.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Enums/Enum1.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ diff --git a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Enums/FlagEnum.generated.cs b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Enums/FlagEnum.generated.cs index 0ff250599..8066cf714 100644 --- a/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Enums/FlagEnum.generated.cs +++ b/src/Testing/EFCoreV5/EFCore5NetCore3/Generated/Enums/FlagEnum.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ diff --git a/src/Testing/Sandbox/Sandbox_EF6/Context2.generated.cs b/src/Testing/Sandbox/Sandbox_EF6/Context2.generated.cs index 2a9488021..5be7e3a5d 100644 --- a/src/Testing/Sandbox/Sandbox_EF6/Context2.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EF6/Context2.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -45,6 +45,8 @@ public Context2(DbContextOptions options) : base(options) /// protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { + optionsBuilder.UseLazyLoadingProxies(); + CustomInit(optionsBuilder); } @@ -60,11 +62,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.HasDefaultSchema("dbo"); modelBuilder.Entity().ToTable("Entity2").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().ValueGeneratedOnAdd(); - modelBuilder.Entity().HasMany(p => p.Entity3).WithOne().HasForeignKey(k => k.Fk).IsRequired(); + modelBuilder.Entity().Property(t => t.Id).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasMany(p => p.Entity3).WithOne().HasForeignKey(k => k.Fk); modelBuilder.Entity().ToTable("Entity3").HasKey(t => t.Id); - modelBuilder.Entity().Property(t => t.Id).IsRequired().ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(t => t.Id).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.Fk).IsRequired(); modelBuilder.Entity().HasIndex(t => t.Fk); diff --git a/src/Testing/Sandbox/Sandbox_EF6/EFModel1.cs b/src/Testing/Sandbox/Sandbox_EF6/EFModel1.cs index 6153a7d78..7e727d005 100644 --- a/src/Testing/Sandbox/Sandbox_EF6/EFModel1.cs +++ b/src/Testing/Sandbox/Sandbox_EF6/EFModel1.cs @@ -1 +1,51 @@  +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +// Produced by Entity Framework Visual Editor v3.0.4.5 +// Source: https://github.com/msawczyn/EFDesigner +// Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner +// Documentation: https://msawczyn.github.io/EFDesigner/ +// License (MIT): https://github.com/msawczyn/EFDesigner/blob/master/LICENSE +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace MultiContext.Context2 +{ + public partial class Entity3 + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected Entity3() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static Entity3 CreateEntity3Unsafe() + { + return new Entity3(); + } + + /// + /// Public constructor with required data + /// + /// Foreign key for Entity2.Entity3 --> Entity3. diff --git a/src/Testing/Sandbox/Sandbox_EF6/Entity2.generated.cs b/src/Testing/Sandbox/Sandbox_EF6/Entity2.generated.cs index fb8f896af..b1b82cb38 100644 --- a/src/Testing/Sandbox/Sandbox_EF6/Entity2.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EF6/Entity2.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -47,7 +47,7 @@ public Entity2() /// [Key] [Required] - public int Id { get; protected set; } + public int Id { get; set; } public string Property1 { get; set; } diff --git a/src/Testing/Sandbox/Sandbox_EF6/Entity3.generated.cs b/src/Testing/Sandbox/Sandbox_EF6/Entity3.generated.cs index efaad27e4..25b957157 100644 --- a/src/Testing/Sandbox/Sandbox_EF6/Entity3.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EF6/Entity3.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.4 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -56,7 +56,6 @@ public Entity3(int fk, global::MultiContext.Context2.Entity2 _entity20) if (_entity20 == null) throw new ArgumentNullException(nameof(_entity20)); _entity20.Entity3.Add(this); - Init(); } @@ -81,13 +80,14 @@ public static Entity3 Create(int fk, global::MultiContext.Context2.Entity2 _enti /// [Key] [Required] - public int Id { get; protected set; } + public int Id { get; set; } /// /// Indexed, Required /// Foreign key for Entity2.Entity3 --> Entity3. /// [Required] + [System.ComponentModel.Description("Foreign key for Entity2.Entity3 --> Entity3. ")] public int Fk { get; set; } /************************************************************************* diff --git a/src/Testing/Sandbox/Sandbox_EF6_Test/Context.generated.cs b/src/Testing/Sandbox/Sandbox_EF6_Test/Context.generated.cs index c7db9db27..ca2fdc74d 100644 --- a/src/Testing/Sandbox/Sandbox_EF6_Test/Context.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EF6_Test/Context.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ diff --git a/src/Testing/Sandbox/Sandbox_EF6_Test/ContextDatabaseInitializer.generated.cs b/src/Testing/Sandbox/Sandbox_EF6_Test/ContextDatabaseInitializer.generated.cs index 77853f79e..821553fc4 100644 --- a/src/Testing/Sandbox/Sandbox_EF6_Test/ContextDatabaseInitializer.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EF6_Test/ContextDatabaseInitializer.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ diff --git a/src/Testing/Sandbox/Sandbox_EF6_Test/ContextDbMigrationConfiguration.generated.cs b/src/Testing/Sandbox/Sandbox_EF6_Test/ContextDbMigrationConfiguration.generated.cs index 1559498d4..1fa004824 100644 --- a/src/Testing/Sandbox/Sandbox_EF6_Test/ContextDbMigrationConfiguration.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EF6_Test/ContextDbMigrationConfiguration.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ diff --git a/src/Testing/Sandbox/Sandbox_EF6_Test/Entity1.generated.cs b/src/Testing/Sandbox/Sandbox_EF6_Test/Entity1.generated.cs index 25ff1c4b5..6c1954fc9 100644 --- a/src/Testing/Sandbox/Sandbox_EF6_Test/Entity1.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EF6_Test/Entity1.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -47,13 +47,17 @@ public Entity1() /// [Key] [Required] - public int Id { get; protected set; } + public int Id { get; set; } /************************************************************************* * Navigation properties *************************************************************************/ + /// + /// Backing field for Entity2 + /// protected ICollection _entity2; + public virtual ICollection Entity2 { get diff --git a/src/Testing/Sandbox/Sandbox_EF6_Test/Entity2.generated.cs b/src/Testing/Sandbox/Sandbox_EF6_Test/Entity2.generated.cs index 802e1319b..80c56e1ac 100644 --- a/src/Testing/Sandbox/Sandbox_EF6_Test/Entity2.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EF6_Test/Entity2.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.0.5 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -45,12 +45,13 @@ public Entity2() /// [Key] [Required] - public int Id { get; protected set; } + public int Id { get; set; } /// /// Indexed /// Foreign key for Entity1.Entity2 <--> Entity2.Entity1. /// + [System.ComponentModel.Description("Foreign key for Entity1.Entity2 <--> Entity2.Entity1. ")] public int? FK { get; set; } /************************************************************************* diff --git a/src/Testing/Sandbox/Sandbox_EFCore/EFModel.tt b/src/Testing/Sandbox/Sandbox_EFCore/EFModel.tt deleted file mode 100644 index 1e503b1d9..000000000 --- a/src/Testing/Sandbox/Sandbox_EFCore/EFModel.tt +++ /dev/null @@ -1,51 +0,0 @@ -<#@ template inherits="Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation" debug="true" - hostSpecific="true" language="C#" compilerOptions="/langversion:latest"#> -<#@ CleanupBehavior processor="T4VSHost" CleanupAfterProcessingtemplate="true" #> -<#@ assembly name="System.Data.Entity.Design.dll" -#><#@ assembly name="EnvDTE" -#><#@ include file="MultipleOutputHelper.ttinclude" once="true" -#><#@ include file="VSIntegration.ttinclude" once="true" -#><#@ include file="EFDesigner.ttinclude" once="true" -#><#@ include file="EF6Designer.ttinclude" once="true" -#><#@ include file="EFCoreDesigner.ttinclude" once="true" -#><#@ output extension=".cs" -#><#@ import namespace="System.Linq" -#><#@ import namespace="System" -#><#@ import namespace="System.Data.Entity.Design.PluralizationServices" -#><#@ import namespace="System.Globalization" -#><#@ import namespace="Sawczyn.EFDesigner.EFModel" -#><#@ EFModel processor="EFModelDirectiveProcessor" requires="FileName='EFModel.efmodel'" -#><# - Manager manager = Manager.Create(Host, GenerationEnvironment); - manager.FileNameMarker = ModelRoot.FileNameMarker; - - if (ModelRoot.Classes.Any()) - { - manager.StartHeader(false); - Output("//------------------------------------------------------------------------------"); - Output("// "); - Output("// This code was generated from a template."); - Output("//"); - Output("// Manual changes to this file may cause unexpected behavior in your application."); - Output("// Manual changes to this file will be overwritten if the code is regenerated."); - Output("//"); - Output("// Produced by Entity Framework Visual Editor"); - Output("// https://github.com/msawczyn/EFDesigner"); - Output("// "); - Output("//------------------------------------------------------------------------------"); - NL(); - - switch (ModelRoot.EntityFrameworkVersion) - { - case EFVersion.EF6: - GenerateEF6(manager, this.ModelRoot); - break; - case EFVersion.EFCore: - GenerateEFCore(manager, this.ModelRoot); - break; - } - - } - - manager.Process(true); -#> \ No newline at end of file diff --git a/src/Testing/Sandbox/Sandbox_EFCore/EFModel1.generated.cs b/src/Testing/Sandbox/Sandbox_EFCore/EFModel1.generated.cs index 124802e65..67562abe2 100644 --- a/src/Testing/Sandbox/Sandbox_EFCore/EFModel1.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EFCore/EFModel1.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.1.0 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -47,6 +47,8 @@ public EFModel1(DbContextOptions options) : base(options) /// protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { + optionsBuilder.UseLazyLoadingProxies(); + CustomInit(optionsBuilder); } @@ -66,12 +68,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasKey(t => t.Id); modelBuilder.Entity() .Property(t => t.Id) - .IsRequired() - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .IsRequired(); modelBuilder.Entity() .HasOne(p => p.EntityImplementation) .WithOne(p => p.Entity1) - .HasForeignKey("Entity1", "EntityImplementationId"); + .HasForeignKey("Entity1", "EntityImplementationId") + .OnDelete(DeleteBehavior.Cascade); modelBuilder.Entity().Navigation(e => e.EntityImplementation).IsRequired(); modelBuilder.Entity() @@ -79,8 +82,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasKey(t => t.Id); modelBuilder.Entity() .Property(t => t.Id) - .IsRequired() - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .IsRequired(); modelBuilder.Entity() .Property(t => t.Test) @@ -91,8 +94,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasKey(t => t.Id); modelBuilder.Entity() .Property(t => t.Id) - .IsRequired() - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .IsRequired(); modelBuilder.Entity() .HasOne(p => p.EntityAbstract) .WithMany(p => p.EntityRelated) diff --git a/src/Testing/Sandbox/Sandbox_EFCore/Entity1.generated.cs b/src/Testing/Sandbox/Sandbox_EFCore/Entity1.generated.cs index 709a1cf65..f1f5c6af0 100644 --- a/src/Testing/Sandbox/Sandbox_EFCore/Entity1.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EFCore/Entity1.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.1.0 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -33,8 +33,6 @@ public partial class Entity1 /// protected Entity1() { - EntityImplementation = new global::EFDesignerCoreTest.EntityImplementation(); - Init(); } @@ -54,7 +52,7 @@ public Entity1(global::EFDesignerCoreTest.EntityImplementation entityimplementat { if (entityimplementation == null) throw new ArgumentNullException(nameof(entityimplementation)); this.EntityImplementation = entityimplementation; - + entityimplementation.Entity1 = this; Init(); } @@ -78,7 +76,8 @@ public static Entity1 Create(global::EFDesignerCoreTest.EntityImplementation ent /// [Key] [Required] - public long Id { get; protected set; } + [System.ComponentModel.Description("Unique identifier")] + public long Id { get; set; } /************************************************************************* * Navigation properties diff --git a/src/Testing/Sandbox/Sandbox_EFCore/EntityAbstract.generated.cs b/src/Testing/Sandbox/Sandbox_EFCore/EntityAbstract.generated.cs index a4aa41df8..c07c0c23b 100644 --- a/src/Testing/Sandbox/Sandbox_EFCore/EntityAbstract.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EFCore/EntityAbstract.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.1.0 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -47,7 +47,7 @@ protected EntityAbstract() /// [Key] [Required] - public long Id { get; protected set; } + public long Id { get; set; } /************************************************************************* * Navigation properties diff --git a/src/Testing/Sandbox/Sandbox_EFCore/EntityImplementation.generated.cs b/src/Testing/Sandbox/Sandbox_EFCore/EntityImplementation.generated.cs index 0a85acc59..feb16ce58 100644 --- a/src/Testing/Sandbox/Sandbox_EFCore/EntityImplementation.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EFCore/EntityImplementation.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.1.0 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -33,8 +33,6 @@ public partial class EntityImplementation: global::EFDesignerCoreTest.EntityAbst /// public EntityImplementation(): base() { - Entity1 = global::EFDesignerCoreTest.Entity1.CreateEntity1Unsafe(); - Init(); } diff --git a/src/Testing/Sandbox/Sandbox_EFCore/EntityRelated.generated.cs b/src/Testing/Sandbox/Sandbox_EFCore/EntityRelated.generated.cs index da2437497..486ada96b 100644 --- a/src/Testing/Sandbox/Sandbox_EFCore/EntityRelated.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EFCore/EntityRelated.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.1.0 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -33,8 +33,6 @@ public partial class EntityRelated /// protected EntityRelated() { - // Assignment of required association EntityAbstract EntityAbstract was not generated because EntityAbstract is abstract. This must be assigned with a concrete object before saving. - Init(); } @@ -54,7 +52,7 @@ public EntityRelated(global::EFDesignerCoreTest.EntityAbstract entityabstract) { if (entityabstract == null) throw new ArgumentNullException(nameof(entityabstract)); this.EntityAbstract = entityabstract; - + entityabstract.EntityRelated.Add(this); Init(); } @@ -77,7 +75,7 @@ public static EntityRelated Create(global::EFDesignerCoreTest.EntityAbstract ent /// [Key] [Required] - public long Id { get; protected set; } + public long Id { get; set; } /************************************************************************* * Navigation properties diff --git a/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/EFCore5ModelGenerator.ttinclude b/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/EFCore5ModelGenerator.ttinclude deleted file mode 100644 index 150354d38..000000000 --- a/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/EFCore5ModelGenerator.ttinclude +++ /dev/null @@ -1,513 +0,0 @@ -<#@ include file="EF6ModelGenerator.ttinclude" once="true" -#><#@ include file="EFCore2ModelGenerator.ttinclude" once="true" -#><#@ include file="EFCore3ModelGenerator.ttinclude" once="true" -#><#@ include file="EFCore5ModelGenerator.ttinclude" once="true" -#><#@ include file="EFCoreModelGenerator.ttinclude" once="true" -#><#@ include file="EFModelFileManager.ttinclude" once="true" -#><#@ include file="EFModelGenerator.ttinclude" once="true" -#><#@ include file="VSIntegration.ttinclude" once="true" -#><#@ assembly name="System.Core" -#><#@ assembly name="System.Data.Linq" -#><#@ assembly name="EnvDTE" -#><#@ assembly name="System.Xml" -#><#@ assembly name="System.Xml.Linq" -#><#@ import namespace="System" -#><#@ import namespace="System.IO" -#><#@ import namespace="System.Globalization" -#><#@ import namespace="System.Linq" -#><#@ import namespace="System.Security" -#><#@ import namespace="System.Text" -#><#@ import namespace="System.Collections.Generic" -#><#@ import namespace="System.Diagnostics.CodeAnalysis" -#><#@ import namespace="EnvDTE" -#><#@ import namespace="System.Data.Entity.Design.PluralizationServices" -#><#@ import namespace="Microsoft.VisualStudio.TextTemplating" -#><#+ - // EFDesigner v3.0.1.1 - // Copyright (c) 2017-2020 Michael Sawczyn - // https://github.com/msawczyn/EFDesigner - - public class EFCore5ModelGenerator : EFCore3ModelGenerator - { - public EFCore5ModelGenerator(GeneratedTextTransformation host) : base(host) { } - - protected override List GatherModelAttributeSegments(ModelAttribute modelAttribute) - { - List segments = base.GatherModelAttributeSegments(modelAttribute); - - if (!string.IsNullOrEmpty(modelAttribute.InitialValue)) - { - switch (modelAttribute.Type) - { - case "String": - segments.Add($"HasDefaultValue(\"{modelAttribute.InitialValue.Trim(' ', '"')}\")"); - break; - case "Char": - segments.Add($"HasDefaultValue('{modelAttribute.InitialValue.Trim(' ', '\'')}')"); - break; - case "DateTime": - if (modelAttribute.InitialValue == "DateTime.UtcNow") - segments.Add("HasDefaultValueSql(\"CURRENT_TIMESTAMP\")"); - break; - default: - segments.Add($"HasDefaultValue({modelAttribute.InitialValue})"); - break; - } - } - - return segments; - } - - - [SuppressMessage("ReSharper", "RedundantNameQualifier")] - protected override void ConfigureBidirectionalAssociations(ModelClass modelClass - , List visited - , List foreignKeyColumns - , List declaredShadowProperties) - { - MakeNonDependentAssociations(); - MakeDependentAssociations(modelClass, $"modelBuilder.Entity<{modelClass.FullName}>()"); - - void MakeNonDependentAssociations() - { - // ReSharper disable once LoopCanBePartlyConvertedToQuery - foreach (BidirectionalAssociation association in Association.GetLinksToTargets(modelClass) - .OfType() - .Where(x => x.Persistent && !x.Target.IsDependentType)) - { - if (visited.Contains(association)) - continue; - - visited.Add(association); - - List segments = new List(); - bool sourceRequired = false; - bool targetRequired = false; - - segments.Add($"modelBuilder.Entity<{modelClass.FullName}>()"); - - switch (association.TargetMultiplicity) // realized by property on source - { - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroMany: - { - segments.Add($"HasMany<{association.Target.FullName}>(p => p.{association.TargetPropertyName})"); - - break; - } - - case Sawczyn.EFDesigner.EFModel.Multiplicity.One: - { - segments.Add($"HasOne<{association.Target.FullName}>(p => p.{association.TargetPropertyName})"); - targetRequired = true; - - break; - } - - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroOne: - { - segments.Add($"HasOne<{association.Target.FullName}>(p => p.{association.TargetPropertyName})"); - - break; - } - } - - switch (association.SourceMultiplicity) // realized by property on target, but no property on target - { - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroMany: - { - segments.Add($"WithMany(p => p.{association.SourcePropertyName})"); - - if (association.TargetMultiplicity == Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroMany) - { - string tableMap = string.IsNullOrEmpty(association.JoinTableName) - ? $"{association.Target.Name}_{association.SourcePropertyName}_x_{association.Source.Name}_{association.TargetPropertyName}" - : association.JoinTableName; - - segments.Add($"UsingEntity(x => x.ToTable(\"{tableMap}\"))"); - } - - break; - } - - case Sawczyn.EFDesigner.EFModel.Multiplicity.One: - { - segments.Add($"WithOne(p => p.{association.SourcePropertyName})"); - sourceRequired = true; - - break; - } - - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroOne: - segments.Add($"WithOne(p => p.{association.SourcePropertyName})"); - - break; - } - - string foreignKeySegment = CreateForeignKeySegment(association, foreignKeyColumns); - - if (!string.IsNullOrEmpty(foreignKeySegment)) - segments.Add(foreignKeySegment); - - if (association.Dependent == association.Target) - { - if (association.SourceDeleteAction == DeleteAction.None) - segments.Add("OnDelete(DeleteBehavior.NoAction)"); - else if (association.SourceDeleteAction == DeleteAction.Cascade) - segments.Add("OnDelete(DeleteBehavior.Cascade)"); - - if (targetRequired) - segments.Add("IsRequired()"); - } - else if (association.Dependent == association.Source) - { - if (association.TargetDeleteAction == DeleteAction.None) - segments.Add("OnDelete(DeleteBehavior.NoAction)"); - else if (association.TargetDeleteAction == DeleteAction.Cascade) - segments.Add("OnDelete(DeleteBehavior.Cascade)"); - - if (sourceRequired) - segments.Add("IsRequired()"); - } - - Output(segments); - - if (association.Principal == association.Target && targetRequired) - Output($"modelBuilder.Entity<{association.Source.FullName}>().Navigation(e => e.{association.TargetPropertyName}).IsRequired();"); - else if (association.Principal == association.Source && sourceRequired) - Output($"modelBuilder.Entity<{association.Target.FullName}>().Navigation(e => e.{association.SourcePropertyName}).IsRequired();"); - } - } - - void MakeDependentAssociations(ModelClass sourceInstance, string baseSegment) - { - // ReSharper disable once LoopCanBePartlyConvertedToQuery - foreach (BidirectionalAssociation association in Association.GetLinksToTargets(sourceInstance) - .OfType() - .Where(x => x.Persistent && x.Target.IsDependentType)) - { - if (visited.Contains(association)) - continue; - - visited.Add(association); - - List segments = new List(); - - switch (association.TargetMultiplicity) // realized by property on source - { - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroMany: - { - segments.Add(baseSegment); - segments.Add($"OwnsMany(p => p.{association.TargetPropertyName})"); - segments.Add($"ToTable(\"{(string.IsNullOrEmpty(association.Target.TableName) ? association.Target.Name : association.Target.TableName)}\")"); - Output(segments); - - segments.Add(baseSegment); - segments.Add($"OwnsMany(p => p.{association.TargetPropertyName})"); - segments.Add($"WithOwner(\"{association.SourcePropertyName}\")"); - segments.Add($"HasForeignKey(\"{association.SourcePropertyName}Id\")"); - Output(segments); - - segments.Add(baseSegment); - segments.Add($"OwnsMany(p => p.{association.TargetPropertyName})"); - segments.Add("Property(\"Id\")"); - - Output(segments); - - segments.Add(baseSegment); - segments.Add($"OwnsMany(p => p.{association.TargetPropertyName})"); - segments.Add("HasKey(\"Id\")"); - - Output(segments); - - MakeDependentAssociations(association.Target, $"{baseSegment}.OwnsMany(p => p.{association.TargetPropertyName})"); - - break; - } - - case Sawczyn.EFDesigner.EFModel.Multiplicity.One: - { - segments.Add(baseSegment); - segments.Add($"OwnsOne(p => p.{association.TargetPropertyName})"); - segments.Add($"WithOwner(p => p.{association.SourcePropertyName})"); - Output(segments); - - if (!string.IsNullOrEmpty(association.Target.TableName)) - { - segments.Add(baseSegment); - segments.Add($"OwnsOne(p => p.{association.TargetPropertyName})"); - segments.Add($"ToTable(\"{association.Target.TableName}\")"); - Output(segments); - } - - foreach (ModelAttribute modelAttribute in association.Target.AllAttributes) - { - segments.Add($"{baseSegment}.OwnsOne(p => p.{association.TargetPropertyName}).Property(p => p.{modelAttribute.Name})"); - - if (modelAttribute.ColumnName != modelAttribute.Name && !string.IsNullOrEmpty(modelAttribute.ColumnName)) - segments.Add($"HasColumnName(\"{modelAttribute.ColumnName}\")"); - - if (modelAttribute.Required) - segments.Add("IsRequired()"); - - if (segments.Count > 1) - Output(segments); - - segments.Clear(); - } - - segments.Add(baseSegment); - segments.Add($"Navigation(p => p.{association.TargetPropertyName}).IsRequired()"); - Output(segments); - - MakeDependentAssociations(association.Target, $"{baseSegment}.OwnsOne(p => p.{association.TargetPropertyName})"); - - break; - } - - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroOne: - { - segments.Add(baseSegment); - segments.Add($"OwnsOne(p => p.{association.TargetPropertyName})"); - segments.Add($"WithOwner(p => p.{association.SourcePropertyName})"); - Output(segments); - - if (!string.IsNullOrEmpty(association.Target.TableName)) - { - segments.Add(baseSegment); - segments.Add($"OwnsOne(p => p.{association.TargetPropertyName})"); - segments.Add($"ToTable(\"{association.Target.TableName}\")"); - Output(segments); - } - - foreach (ModelAttribute modelAttribute in association.Target.AllAttributes) - { - segments.Add($"{baseSegment}.OwnsOne(p => p.{association.TargetPropertyName}).Property(p => p.{modelAttribute.Name})"); - - if (modelAttribute.ColumnName != modelAttribute.Name && !string.IsNullOrEmpty(modelAttribute.ColumnName)) - segments.Add($"HasColumnName(\"{modelAttribute.ColumnName}\")"); - - if (modelAttribute.Required) - segments.Add("IsRequired()"); - - if (segments.Count > 1) - Output(segments); - - segments.Clear(); - } - - MakeDependentAssociations(association.Target, $"{baseSegment}.OwnsOne(p => p.{association.TargetPropertyName})"); - - break; - } - } - } - } - } - - [SuppressMessage("ReSharper", "RedundantNameQualifier")] - protected override void ConfigureUnidirectionalAssociations(ModelClass modelClass - , List visited - , List foreignKeyColumns - , List declaredShadowProperties) - { - MakeNonDependentAssociations(); - MakeDependentAssociations(modelClass, $"modelBuilder.Entity<{modelClass.FullName}>()"); - - void MakeNonDependentAssociations() - { - // ReSharper disable once LoopCanBePartlyConvertedToQuery - foreach (UnidirectionalAssociation association in Association.GetLinksToTargets(modelClass) - .OfType() - .Where(x => x.Persistent && !x.Target.IsDependentType)) - { - if (visited.Contains(association)) - continue; - - visited.Add(association); - - List segments = new List(); - bool sourceRequired = false; - bool targetRequired = false; - - segments.Add($"modelBuilder.Entity<{modelClass.FullName}>()"); - - switch (association.TargetMultiplicity) // realized by property on source - { - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroMany: - segments.Add($"HasMany<{association.Target.FullName}>(p => p.{association.TargetPropertyName})"); - - break; - - case Sawczyn.EFDesigner.EFModel.Multiplicity.One: - segments.Add($"HasOne<{association.Target.FullName}>(p => p.{association.TargetPropertyName})"); - targetRequired = true; - - break; - - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroOne: - segments.Add($"HasOne<{association.Target.FullName}>(p => p.{association.TargetPropertyName})"); - - break; - } - - switch (association.SourceMultiplicity) // realized by property on target, but no property on target - { - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroMany: - segments.Add("WithMany()"); - - if (association.TargetMultiplicity == Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroMany) - { - string tableMap = string.IsNullOrEmpty(association.JoinTableName) - ? $"{association.Target.Name}_x_{association.Source.Name}_{association.TargetPropertyName}" - : association.JoinTableName; - - segments.Add($"UsingEntity(x => x.ToTable(\"{tableMap}\"))"); - } - - break; - - case Sawczyn.EFDesigner.EFModel.Multiplicity.One: - segments.Add("WithOne()"); - sourceRequired = true; - - break; - - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroOne: - segments.Add("WithOne()"); - - break; - } - - string foreignKeySegment = CreateForeignKeySegment(association, foreignKeyColumns); - - if (!string.IsNullOrEmpty(foreignKeySegment)) - segments.Add(foreignKeySegment); - - if (association.Dependent == association.Target) - { - if (association.SourceDeleteAction == DeleteAction.None) - segments.Add("OnDelete(DeleteBehavior.NoAction)"); - else if (association.SourceDeleteAction == DeleteAction.Cascade) - segments.Add("OnDelete(DeleteBehavior.Cascade)"); - - if (targetRequired) - segments.Add("IsRequired()"); - } - else if (association.Dependent == association.Source) - { - if (association.TargetDeleteAction == DeleteAction.None) - segments.Add("OnDelete(DeleteBehavior.NoAction)"); - else if (association.TargetDeleteAction == DeleteAction.Cascade) - segments.Add("OnDelete(DeleteBehavior.Cascade)"); - - if (sourceRequired) - segments.Add("IsRequired()"); - } - - if (association.Principal == association.Target && targetRequired) - Output($"modelBuilder.Entity<{association.Source.FullName}>().Navigation(e => e.{association.TargetPropertyName}).IsRequired();"); - - Output(segments); - - if (!association.TargetAutoProperty) - { - segments.Add($"modelBuilder.Entity<{association.Source.FullName}>().Navigation(e => e.{association.TargetPropertyName})"); - segments.Add($"HasField(\"{association.TargetBackingFieldName}\")"); - segments.Add($"UsePropertyAccessMode(PropertyAccessMode.{association.TargetPropertyAccessMode})"); - Output(segments); - } - } - } - - void MakeDependentAssociations(ModelClass sourceInstance, string baseSegment) - { - // ReSharper disable once LoopCanBePartlyConvertedToQuery - foreach (UnidirectionalAssociation association in Association.GetLinksToTargets(sourceInstance) - .OfType() - .Where(x => x.Persistent && x.Target.IsDependentType)) - { - if (visited.Contains(association)) - continue; - - visited.Add(association); - - List segments = new List(); - - switch (association.TargetMultiplicity) // realized by property on source - { - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroMany: - { - segments.Add(baseSegment); - segments.Add($"OwnsMany(p => p.{association.TargetPropertyName})"); - segments.Add($"WithOwner(\"{association.Source.Name}_{association.TargetPropertyName}\")"); - segments.Add($"HasForeignKey(\"{association.Source.Name}_{association.TargetPropertyName}Id\")"); - Output(segments); - - segments.Add(baseSegment); - segments.Add($"OwnsMany(p => p.{association.TargetPropertyName})"); - segments.Add("Property(\"Id\")"); - - Output(segments); - - segments.Add(baseSegment); - segments.Add($"OwnsMany(p => p.{association.TargetPropertyName})"); - segments.Add("HasKey(\"Id\")"); - - Output(segments); - - MakeDependentAssociations(association.Target, $"{baseSegment}.OwnsMany(p => p.{association.TargetPropertyName})"); - - break; - } - - case Sawczyn.EFDesigner.EFModel.Multiplicity.One: - { - foreach (ModelAttribute modelAttribute in association.Target.AllAttributes) - { - segments.Add($"{baseSegment}.OwnsOne(p => p.{association.TargetPropertyName}).Property(p => p.{modelAttribute.Name})"); - - if (modelAttribute.ColumnName != modelAttribute.Name && !string.IsNullOrEmpty(modelAttribute.ColumnName)) - segments.Add($"HasColumnName(\"{modelAttribute.ColumnName}\")"); - - if (modelAttribute.Required) - segments.Add("IsRequired()"); - - Output(segments); - } - - segments.Add(baseSegment); - segments.Add($"Navigation(p => p.{association.TargetPropertyName}).IsRequired()"); - Output(segments); - - MakeDependentAssociations(association.Target, $"{baseSegment}.OwnsOne(p => p.{association.TargetPropertyName})"); - - break; - } - - case Sawczyn.EFDesigner.EFModel.Multiplicity.ZeroOne: - { - foreach (ModelAttribute modelAttribute in association.Target.AllAttributes) - { - segments.Add($"{baseSegment}.OwnsOne(p => p.{association.TargetPropertyName}).Property(p => p.{modelAttribute.Name})"); - - if (modelAttribute.ColumnName != modelAttribute.Name && !string.IsNullOrEmpty(modelAttribute.ColumnName)) - segments.Add($"HasColumnName(\"{modelAttribute.ColumnName}\")"); - - if (modelAttribute.Required) - segments.Add("IsRequired()"); - - Output(segments); - } - - MakeDependentAssociations(association.Target, $"{baseSegment}.OwnsOne(p => p.{association.TargetPropertyName})"); - - break; - } - } - } - } - } - } - - -#> diff --git a/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EFModel1.generated.cs b/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EFModel1.generated.cs index d3e61aa29..5228f83f2 100644 --- a/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EFModel1.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EFModel1.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.1.1 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -44,12 +44,6 @@ public EFModel1(DbContextOptions options) : base(options) partial void CustomInit(DbContextOptionsBuilder optionsBuilder); - /// - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - CustomInit(optionsBuilder); - } - partial void OnModelCreatingImpl(ModelBuilder modelBuilder); partial void OnModelCreatedImpl(ModelBuilder modelBuilder); @@ -91,7 +85,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasDefaultValue("default string"); modelBuilder.Entity() .Property(t => t.Property1) - .HasDefaultValueSql("CURRENT_TIMESTAMP"); + .HasDefaultValue(DateTime.UtcNow); modelBuilder.Entity() .Property(t => t.Property11) .HasDefaultValue(3); diff --git a/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EFModel1Factory.generated.cs b/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EFModel1Factory.generated.cs index 3bfd9f73d..e1b97e0b7 100644 --- a/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EFModel1Factory.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EFModel1Factory.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.1.1 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -24,11 +24,17 @@ namespace Testing { + /// + /// A factory for creating derived DbContext instances. Implement this interface to enable design-time services for context + /// types that do not have a public default constructor. At design-time, derived DbContext instances can be created in order + /// to enable specific design-time experiences such as Migrations. Design-time services will automatically discover + /// implementations of this interface that are in the startup assembly or the same assembly as the derived context. + /// public class EFModel1Factory: IDesignTimeDbContextFactory { /// Creates a new instance of a derived context. /// Arguments provided by the design-time service. - /// An instance of . + /// An instance of . public EFModel1 CreateDbContext(string[] args) { DbContextOptionsBuilder optionsBuilder = new DbContextOptionsBuilder(); diff --git a/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/Entity1.generated.cs b/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/Entity1.generated.cs index ec9f1ff75..799f45852 100644 --- a/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/Entity1.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/Entity1.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.1.1 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -33,8 +33,6 @@ public partial class Entity1 /// protected Entity1() { - EntityImplementation = new global::Testing.EntityImplementation(); - Init(); } @@ -54,7 +52,7 @@ public Entity1(global::Testing.EntityImplementation entityimplementation) { if (entityimplementation == null) throw new ArgumentNullException(nameof(entityimplementation)); this.EntityImplementation = entityimplementation; - + entityimplementation.Entity1 = this; Init(); } @@ -78,7 +76,8 @@ public static Entity1 Create(global::Testing.EntityImplementation entityimplemen /// [Key] [Required] - public long Id { get; protected set; } + [System.ComponentModel.Description("Unique identifier")] + public long Id { get; set; } /************************************************************************* * Navigation properties diff --git a/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EntityAbstract.generated.cs b/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EntityAbstract.generated.cs index 33d687410..5899f29ef 100644 --- a/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EntityAbstract.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EntityAbstract.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.1.1 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -47,7 +47,7 @@ protected EntityAbstract() /// [Key] [Required] - public long Id { get; protected set; } + public long Id { get; set; } /************************************************************************* * Navigation properties diff --git a/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EntityImplementation.generated.cs b/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EntityImplementation.generated.cs index efc52df79..483adba08 100644 --- a/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EntityImplementation.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EntityImplementation.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.1.1 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -37,7 +37,6 @@ public EntityImplementation(): base() Property1 = DateTime.UtcNow; Property11 = 3; Property12 = true; - Entity1 = global::Testing.Entity1.CreateEntity1Unsafe(); Init(); } diff --git a/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EntityRelated.generated.cs b/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EntityRelated.generated.cs index 65af9c959..a13f84d8d 100644 --- a/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EntityRelated.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EFCore3NetCore3/Generated/EntityRelated.generated.cs @@ -5,7 +5,7 @@ // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // -// Produced by Entity Framework Visual Editor v3.0.1.1 +// Produced by Entity Framework Visual Editor v3.0.4.5 // Source: https://github.com/msawczyn/EFDesigner // Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner // Documentation: https://msawczyn.github.io/EFDesigner/ @@ -33,8 +33,6 @@ public partial class EntityRelated /// protected EntityRelated() { - // Assignment of required association EntityAbstract EntityAbstract was not generated because EntityAbstract is abstract. This must be assigned with a concrete object before saving. - Init(); } @@ -54,7 +52,7 @@ public EntityRelated(global::Testing.EntityAbstract entityabstract) { if (entityabstract == null) throw new ArgumentNullException(nameof(entityabstract)); this.EntityAbstract = entityabstract; - + entityabstract.EntityRelated.Add(this); Init(); } @@ -77,7 +75,7 @@ public static EntityRelated Create(global::Testing.EntityAbstract entityabstract /// [Key] [Required] - public long Id { get; protected set; } + public long Id { get; set; } /************************************************************************* * Navigation properties diff --git a/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Context.cs b/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Context.cs index 6153a7d78..998af194a 100644 --- a/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Context.cs +++ b/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Context.cs @@ -1 +1,185 @@  +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +// Produced by Entity Framework Visual Editor +// Source: https://github.com/msawczyn/EFDesigner +// Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner +// Documentation: https://msawczyn.github.io/EFDesigner/ +// License (MIT): https://github.com/msawczyn/EFDesigner/blob/master/LICENSE +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Sandbox_EFCore5NetCore3_Test +{ + public partial class Entity1 + { + partial void Init(); + + /// + /// Default constructor + /// + public Entity1() + { + Entity2 = new System.Collections.Generic.HashSet(); + + Init(); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Identity, Indexed, Required + /// Unique identifier + /// + [Key] + [Required] + [System.ComponentModel.Description("Unique identifier")] + public long Id { get; set; } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + public virtual ICollection Entity2 { get; private set; } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Sandbox_EFCore5NetCore3_Test +{ + public partial class Entity2 + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected Entity2() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static Entity2 CreateEntity2Unsafe() + { + return new Entity2(); + } + + /// + /// Public constructor with required data + /// + /// + /// + public Entity2(long property1, global::Sandbox_EFCore5NetCore3_Test.Entity1 entity1) + { + this.Property1 = property1; + + if (entity1 == null) throw new ArgumentNullException(nameof(entity1)); + this.Entity1 = entity1; + entity1.Entity2.Add(this); + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + /// + public static Entity2 Create(long property1, global::Sandbox_EFCore5NetCore3_Test.Entity1 entity1) + { + return new Entity2(property1, entity1); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Identity, Indexed, Required + /// Unique identifier + /// + [Key] + [Required] + [System.ComponentModel.Description("Unique identifier")] + public long Id { get; set; } + + /// + /// Required + /// + [Required] + public long Property1 { get; set; } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + /// + /// Required + /// + public virtual global::Sandbox_EFCore5NetCore3_Test.Entity1 Entity1 { get; set; } + + } +} + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Sandbox_EFCore5NetCore3_Test +{ + public partial class Entity3 + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected Entity3() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static Entity3 CreateEntity3Unsafe() + { + return new Entity3(); + } + + /// + /// Public constructor with required data + /// diff --git a/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Context.efmodel b/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Context.efmodel index b58a5b5a3..e79c08277 100644 --- a/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Context.efmodel +++ b/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Context.efmodel @@ -1,5 +1,5 @@  - + @@ -22,14 +22,19 @@ - + - + + + + + + diff --git a/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Context.efmodel.diagramx b/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Context.efmodel.diagramx index df2c5a0a4..4e6ad42fd 100644 --- a/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Context.efmodel.diagramx +++ b/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Context.efmodel.diagramx @@ -21,7 +21,7 @@ - + @@ -29,24 +29,32 @@ - + - - - + + + - + - - + + + + + + + + + + diff --git a/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Generated/Context/Context.generated.cs b/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Generated/Context/Context.generated.cs index 59dcf6eb3..7fcaf2309 100644 --- a/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Generated/Context/Context.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Generated/Context/Context.generated.cs @@ -27,6 +27,8 @@ public partial class Context : DbContext #region DbSets public virtual Microsoft.EntityFrameworkCore.DbSet Entity1 { get; set; } public virtual Microsoft.EntityFrameworkCore.DbSet Entity2 { get; set; } + public virtual Microsoft.EntityFrameworkCore.DbSet Entity3 { get; set; } + public virtual Microsoft.EntityFrameworkCore.DbSet Entity4 { get; set; } #endregion DbSets @@ -71,6 +73,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(t => t.Id).ValueGeneratedOnAdd().IsRequired(); modelBuilder.Entity().Property(t => t.Property1).IsRequired(); + modelBuilder.Entity().ToTable("Entity3").HasKey(t => t.Id); + modelBuilder.Entity().Property(t => t.Id).ValueGeneratedOnAdd().IsRequired(); + + modelBuilder.Entity().ToTable("Entity4").HasKey(t => t.Id); + modelBuilder.Entity().Property(t => t.Id).ValueGeneratedOnAdd().IsRequired(); + modelBuilder.Entity().HasMany(p => p.Entity3).WithOne().HasForeignKey("Entity4Entity3Id"); + OnModelCreatedImpl(modelBuilder); } } diff --git a/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Generated/Entities/Entity1.generated.cs b/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Generated/Entities/Entity1.generated.cs index e784bcfba..0da3a9d8c 100644 --- a/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Generated/Entities/Entity1.generated.cs +++ b/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Generated/Entities/Entity1.generated.cs @@ -24,7 +24,7 @@ namespace Sandbox_EFCore5NetCore3_Test { - public partial class Entity1: IValidatableObject + public partial class Entity1 { partial void Init(); diff --git a/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Generated/Entities/Entity3.generated.cs b/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Generated/Entities/Entity3.generated.cs new file mode 100644 index 000000000..285488add --- /dev/null +++ b/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Generated/Entities/Entity3.generated.cs @@ -0,0 +1,87 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +// Produced by Entity Framework Visual Editor +// Source: https://github.com/msawczyn/EFDesigner +// Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner +// Documentation: https://msawczyn.github.io/EFDesigner/ +// License (MIT): https://github.com/msawczyn/EFDesigner/blob/master/LICENSE +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Sandbox_EFCore5NetCore3_Test +{ + public partial class Entity3 + { + partial void Init(); + + /// + /// Default constructor. Protected due to required properties, but present because EF needs it. + /// + protected Entity3() + { + Init(); + } + + /// + /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. + /// + public static Entity3 CreateEntity3Unsafe() + { + return new Entity3(); + } + + /// + /// Public constructor with required data + /// + /// + public Entity3(global::Sandbox_EFCore5NetCore3_Test.Entity4 _entity40) + { + if (_entity40 == null) throw new ArgumentNullException(nameof(_entity40)); + _entity40.Entity3.Add(this); + + Init(); + } + + /// + /// Static create function (for use in LINQ queries, etc.) + /// + /// + public static Entity3 Create(global::Sandbox_EFCore5NetCore3_Test.Entity4 _entity40) + { + return new Entity3(_entity40); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Identity, Indexed, Required + /// Unique identifier + /// + [Key] + [Required] + [System.ComponentModel.Description("Unique identifier")] + public long Id { get; set; } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + } +} + diff --git a/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Generated/Entities/Entity4.generated.cs b/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Generated/Entities/Entity4.generated.cs new file mode 100644 index 000000000..620f03638 --- /dev/null +++ b/src/Testing/Sandbox/Sandbox_EFCore5Net5_Test/Generated/Entities/Entity4.generated.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +// Produced by Entity Framework Visual Editor +// Source: https://github.com/msawczyn/EFDesigner +// Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner +// Documentation: https://msawczyn.github.io/EFDesigner/ +// License (MIT): https://github.com/msawczyn/EFDesigner/blob/master/LICENSE +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Sandbox_EFCore5NetCore3_Test +{ + public partial class Entity4 + { + partial void Init(); + + /// + /// Default constructor + /// + public Entity4() + { + Entity3 = new System.Collections.Generic.HashSet(); + + Init(); + } + + /************************************************************************* + * Properties + *************************************************************************/ + + /// + /// Identity, Indexed, Required + /// Unique identifier + /// + [Key] + [Required] + [System.ComponentModel.Description("Unique identifier")] + public long Id { get; set; } + + /************************************************************************* + * Navigation properties + *************************************************************************/ + + public virtual ICollection Entity3 { get; private set; } + + } +} +