/// <summary>
 ///     Removes the given owned type, indicating that when discovered matching entity types
 ///     should not be configured as owned.
 /// </summary>
 /// <param name="model"> The model to remove the owned type name from. </param>
 /// <param name="type"> The type of the entity type that should not be owned. </param>
 /// <returns> The name of the removed owned type. </returns>
 public static string RemoveOwned([NotNull] this IMutableModel model, [NotNull] Type type)
 => Check.NotNull((Model)model, nameof(model)).RemoveOwned(
     Check.NotNull(type, nameof(type)));
Exemple #2
0
 /// <summary>
 ///     Sets the default identity seed.
 /// </summary>
 /// <param name="model"> The model. </param>
 /// <param name="seed"> The value to set. </param>
 public static void SetSqlServerIdentitySeed([NotNull] this IMutableModel model, int?seed)
 => model.SetOrRemoveAnnotation(
     SqlServerAnnotationNames.IdentitySeed,
     seed);
Exemple #3
0
 /// <summary>
 ///     Attempts to set the <see cref="SqlServerValueGenerationStrategy" /> to use for properties
 ///     of keys in the model that don't have a strategy explicitly set.
 /// </summary>
 /// <param name="model"> The model. </param>
 /// <param name="value"> The value to set. </param>
 public static void SetSqlServerValueGenerationStrategy([NotNull] this IMutableModel model, SqlServerValueGenerationStrategy?value)
 => model.SetOrRemoveAnnotation(SqlServerAnnotationNames.ValueGenerationStrategy, value);
Exemple #4
0
 /// <summary>
 ///     Returns all functions contained in the model.
 /// </summary>
 /// <param name="model"> The model to get the functions in. </param>
 public static IEnumerable <IMutableDbFunction> GetDbFunctions(this IMutableModel model)
 => DbFunction.GetDbFunctions(Check.NotNull(model, nameof(model))).Cast <IMutableDbFunction>();
Exemple #5
0
 /// <summary>
 ///     Sets the maximum length allowed for store identifiers.
 /// </summary>
 /// <param name="model"> The model to set the default schema for. </param>
 /// <param name="length"> The value to set. </param>
 public static void SetMaxIdentifierLength(this IMutableModel model, int?length)
 => model.SetOrRemoveAnnotation(RelationalAnnotationNames.MaxIdentifierLength, length);
Exemple #6
0
 /// <summary>
 ///     Creates an <see cref="IMutableDbFunction" /> mapped to the given method.
 /// </summary>
 /// <param name="model"> The model to add the function to. </param>
 /// <param name="methodInfo"> The <see cref="MethodInfo" /> for the method that is mapped to the function. </param>
 /// <returns> The new <see cref="IMutableDbFunction" />. </returns>
 public static IMutableDbFunction AddDbFunction(this IMutableModel model, MethodInfo methodInfo)
 => DbFunction.AddDbFunction(
     model, Check.NotNull(methodInfo, nameof(methodInfo)), ConfigurationSource.Explicit) !;
Exemple #7
0
 /// <summary>
 ///     Removes the function that is mapped to the method represented by the given
 ///     <see cref="MethodInfo" />.
 /// </summary>
 /// <param name="model"> The model to find the function in. </param>
 /// <param name="method"> The <see cref="MethodInfo" /> for the method that is mapped to the function. </param>
 /// <returns> The removed function or <see langword="null" /> if the method is not mapped. </returns>
 public static IMutableDbFunction?RemoveDbFunction(this IMutableModel model, MethodInfo method)
 => DbFunction.RemoveDbFunction(
     Check.NotNull(model, nameof(model)),
     Check.NotNull(method, nameof(method)));
 /// <summary>
 ///     Sets the maximum size of the database.
 /// </summary>
 /// <param name="model"> The model. </param>
 /// <param name="value"> The value to set. </param>
 public static void SetDatabaseMaxSize([NotNull] this IMutableModel model, [CanBeNull] string value)
 => model.SetOrRemoveAnnotation(SqlServerAnnotationNames.MaxDatabaseSize, value);
 /// <summary>
 ///     Sets the service tier of the database.
 /// </summary>
 /// <param name="model"> The model. </param>
 /// <param name="value"> The value to set. </param>
 public static void SetServiceTier([NotNull] this IMutableModel model, [CanBeNull] string value)
 => model.SetOrRemoveAnnotation(SqlServerAnnotationNames.ServiceTier, value);
 /// <summary>
 ///     Gets the entity type for the given name, defining navigation name
 ///     and the defining entity type. Returns <see langword="null" /> if no matching entity type is found.
 /// </summary>
 /// <param name="model"> The model to find the entity type in. </param>
 /// <param name="type"> The type of the entity type to find. </param>
 /// <param name="definingNavigationName"> The defining navigation of the entity type to find. </param>
 /// <param name="definingEntityType"> The defining entity type of the entity type to find. </param>
 /// <returns> The entity type, or <see langword="null" /> if none are found. </returns>
 public static IMutableEntityType FindEntityType(
     [NotNull] this IMutableModel model,
     [NotNull] Type type,
     [NotNull] string definingNavigationName,
     [NotNull] IMutableEntityType definingEntityType)
 => (IMutableEntityType)((IModel)model).FindEntityType(type, definingNavigationName, definingEntityType);
 public static IReadOnlyCollection <IMutableEntityType> GetEntityTypes([NotNull] this IMutableModel model, [NotNull] string name)
 => ((Model)model).GetEntityTypes(name);
 /// <summary>
 ///     Gets the entity that maps the given entity class. Returns <see langword="null" /> if no entity type with
 ///     the given CLR type is found or the given CLR type is being used by shared type entity type
 ///     or the entity type has a defining navigation.
 /// </summary>
 /// <param name="model"> The model to find the entity type in. </param>
 /// <param name="type"> The type to find the corresponding entity type for. </param>
 /// <returns> The entity type, or <see langword="null" /> if none if found. </returns>
 public static IMutableEntityType FindEntityType([NotNull] this IMutableModel model, [NotNull] Type type)
 => (IMutableEntityType)((IModel)model).FindEntityType(type);
 /// <summary>
 ///     Forces post-processing on the model such that it is ready for use by the runtime. This post
 ///     processing happens automatically when using <see cref="DbContext.OnModelCreating" />; this method allows it to be run
 ///     explicitly in cases where the automatic execution is not possible.
 /// </summary>
 /// <param name="model"> The model to finalize. </param>
 /// <returns> The finalized <see cref="IModel" />. </returns>
 public static IModel FinalizeModel([NotNull] this IMutableModel model)
 => ((Model)model).FinalizeModel();
 /// <summary>
 ///     Marks the given entity type as shared, indicating that when discovered matching entity types
 ///     should be configured as shared type entity type.
 /// </summary>
 /// <param name="model"> The model to add the shared type to. </param>
 /// <param name="type"> The type of the entity type that should be shared. </param>
 public static void AddShared([NotNull] this IMutableModel model, [NotNull] Type type)
 => Check.NotNull((Model)model, nameof(model)).AddShared(
     Check.NotNull(type, nameof(type)), ConfigurationSource.Explicit);
Exemple #15
0
 /// <summary>
 ///     Finds a function that is mapped to the method represented by the given <see cref="MethodInfo" />.
 /// </summary>
 /// <param name="model"> The model to find the function in. </param>
 /// <param name="method"> The <see cref="MethodInfo" /> for the method that is mapped to the function. </param>
 /// <returns> The function or <see langword="null" /> if the method is not mapped. </returns>
 public static IMutableDbFunction?FindDbFunction(this IMutableModel model, MethodInfo method)
 => (IMutableDbFunction?)((IReadOnlyModel)model).FindDbFunction(method);
 /// <summary>
 ///     Sets the performance level of the database.
 /// </summary>
 /// <param name="model"> The model. </param>
 /// <param name="value"> The value to set. </param>
 public static void SetPerformanceLevel([NotNull] this IMutableModel model, [CanBeNull] string value)
 => model.SetOrRemoveAnnotation(SqlServerAnnotationNames.PerformanceLevel, value);
Exemple #17
0
 /// <summary>
 ///     Finds a function that is mapped to the method represented by the given name.
 /// </summary>
 /// <param name="model"> The model to find the function in. </param>
 /// <param name="name"> The model name of the function. </param>
 /// <returns> The function or <see langword="null" /> if the method is not mapped. </returns>
 public static IMutableDbFunction?FindDbFunction(this IMutableModel model, string name)
 => (IMutableDbFunction?)((IReadOnlyModel)model).FindDbFunction(name);
        /// <summary>
        ///     Sets the schema to use for the default hi-lo sequence.
        /// </summary>
        /// <param name="model"> The model. </param>
        /// <param name="value"> The value to set. </param>
        public static void SetHiLoSequenceSchema([NotNull] this IMutableModel model, [CanBeNull] string value)
        {
            Check.NullButNotEmpty(value, nameof(value));

            model.SetOrRemoveAnnotation(SqlServerAnnotationNames.HiLoSequenceSchema, value);
        }
Exemple #19
0
 /// <summary>
 ///     Creates a function.
 /// </summary>
 /// <param name="model"> The model to add the function to. </param>
 /// <param name="name"> The model name of the function. </param>
 /// <param name="returnType"> The function return type. </param>
 /// <returns> The new function. </returns>
 public static IMutableDbFunction AddDbFunction(
     this IMutableModel model,
     string name,
     Type returnType)
 => DbFunction.AddDbFunction(
     model, Check.NotNull(name, nameof(name)), returnType, ConfigurationSource.Explicit);
 public static void SetKeyspace(this IMutableModel model, string name, KeyspaceReplicationConfiguration keyspaceReplicationConfiguration)
 {
     model.SetOrRemoveAnnotation($"{CassandraAnnotationNames.Keyspace}{name}", JsonConvert.SerializeObject(keyspaceReplicationConfiguration));
 }
Exemple #21
0
 /// <summary>
 ///     Removes the function that is mapped to the method represented by the given
 ///     <see cref="MethodInfo" />.
 /// </summary>
 /// <param name="model"> The model to find the function in. </param>
 /// <param name="name"> The model name of the function. </param>
 /// <returns> The removed function or <see langword="null" /> if the method is not mapped. </returns>
 public static IMutableDbFunction?RemoveDbFunction(this IMutableModel model, string name)
 => DbFunction.RemoveDbFunction(
     Check.NotNull(model, nameof(model)),
     Check.NotNull(name, nameof(name)));
Exemple #22
0
 /// <summary>
 ///     Finds a sequence with the given name.
 /// </summary>
 /// <param name="model"> The model to find the sequence in. </param>
 /// <param name="name"> The sequence name. </param>
 /// <param name="schema"> The schema that contains the sequence. </param>
 /// <returns>
 ///     The sequence or <see langword="null" /> if no sequence with the given name in
 ///     the given schema was found.
 /// </returns>
 public static IMutableSequence?FindSequence(
     this IMutableModel model,
     string name,
     string?schema = null)
 => (IMutableSequence?)((IReadOnlyModel)model).FindSequence(name, schema);
Exemple #23
0
 /// <summary>
 ///     Sets the database collation.
 /// </summary>
 /// <param name="model"> The model to set the collation for. </param>
 /// <param name="value"> The value to set. </param>
 public static void SetCollation(this IMutableModel model, string?value)
 => model.SetOrRemoveAnnotation(
     RelationalAnnotationNames.Collation,
     Check.NullButNotEmpty(value, nameof(value)));
Exemple #24
0
 /// <summary>
 ///     Either returns the existing <see cref="IMutableSequence" /> with the given name in the given schema
 ///     or creates a new sequence with the given name and schema.
 /// </summary>
 /// <param name="model"> The model to add the sequence to. </param>
 /// <param name="name"> The sequence name. </param>
 /// <param name="schema"> The schema name, or <see langword="null" /> to use the default schema. </param>
 /// <returns> The sequence. </returns>
 public static IMutableSequence AddSequence(
     this IMutableModel model,
     string name,
     string?schema = null)
 => Sequence.AddSequence(model, name, schema, ConfigurationSource.Explicit);
Exemple #25
0
 /// <summary>
 ///     Sets the default container name.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="name">The name to set.</param>
 public static void SetDefaultContainer(this IMutableModel model, string?name)
 => model.SetOrRemoveAnnotation(
     CosmosAnnotationNames.ContainerName,
     Check.NullButNotEmpty(name, nameof(name)));
Exemple #26
0
 /// <summary>
 ///     Removes the <see cref="IMutableSequence" /> with the given name.
 /// </summary>
 /// <param name="model"> The model to find the sequence in. </param>
 /// <param name="name"> The sequence name. </param>
 /// <param name="schema"> The schema that contains the sequence. </param>
 /// <returns>
 ///     The removed <see cref="IMutableSequence" /> or <see langword="null" /> if no sequence with the given name in
 ///     the given schema was found.
 /// </returns>
 public static IMutableSequence?RemoveSequence(
     this IMutableModel model,
     string name,
     string?schema = null)
 => Sequence.RemoveSequence(Check.NotNull(model, nameof(model)), name, schema);
Exemple #27
0
 /// <summary>
 ///     Sets the default identity increment.
 /// </summary>
 /// <param name="model"> The model. </param>
 /// <param name="increment"> The value to set. </param>
 public static void SetSqlServerIdentityIncrement([NotNull] this IMutableModel model, int?increment)
 => model.SetOrRemoveAnnotation(
     SqlServerAnnotationNames.IdentityIncrement,
     increment);
Exemple #28
0
 /// <summary>
 ///     Returns all sequences contained in the model.
 /// </summary>
 /// <param name="model"> The model to get the sequences in. </param>
 public static IEnumerable <IMutableSequence> GetSequences(this IMutableModel model)
 => Sequence.GetSequences(Check.NotNull(model, nameof(model))).Cast <IMutableSequence>();
Exemple #29
0
        /// <summary>
        ///     Sets the name to use for the default hi-lo sequence.
        /// </summary>
        /// <param name="model"> The model. </param>
        /// <param name="name"> The value to set. </param>
        public static void SetSqlServerHiLoSequenceName([NotNull] this IMutableModel model, [CanBeNull] string name)
        {
            Check.NullButNotEmpty(name, nameof(name));

            model.SetOrRemoveAnnotation(SqlServerAnnotationNames.HiLoSequenceName, name);
        }
 /// <summary>
 ///     Returns a value indicating whether the entity types using the given type should be configured
 ///     as owned types when discovered by conventions.
 /// </summary>
 /// <param name="model"> The model to get the value from. </param>
 /// <param name="type"> The type of the entity type that might be owned. </param>
 /// <returns>
 ///     <see langword="true" /> if a matching entity type should be configured as owned when discovered,
 ///     <see langword="false" /> otherwise.
 /// </returns>
 public static bool IsOwned([NotNull] this IMutableModel model, [NotNull] Type type)
 => Check.NotNull((Model)model, nameof(model)).IsOwned(
     Check.NotNull(type, nameof(type)));