You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With MORYX 10, several changes have been made to the data model to improve performance and maintainability. Notable changes include:
27
28
28
-
The `ProductFileEntity` was not used in the product-model. There was no api to access it in a simple way. With the implementation of the [`FileSystem`](https://github.com/PHOENIXCONTACT/MORYX-Framework/pull/517) it is also not required anymore.
29
+
- Harmonized Naming Conventions: Naming conventions across the data model have been standardized to ensure consistency and clarity.
30
+
- Derived data models are now fully supported. This needs some changes how the model is defined in code first scenarios. Please refer to the [Data Model Tutorial](/docs/tutorials/data-model/CodeFirst.md) for more information.
31
+
32
+
### Removal of ProductFileEntity
33
+
34
+
The `ProductFileEntity` has been removed from the data model as it was not utilized effectively. This change helps streamline the data structure and reduce unnecessary complexity.
//Optional: If Moryx.Model.InMemory is used for testing
33
+
//Necessary for DesignTimeDbContextFactory
34
34
}
35
35
36
36
publicvirtualDbSet<Planet> Planets { get; set; }
@@ -48,6 +48,50 @@ public class SolarSystemContext : MoryxDbContext
48
48
}
49
49
````
50
50
51
+
If you want to provide database provider specific implementations you can derive from this context. The database specific attribute provides an argument for the base context. This is important to use the base context in a generic way, without knowledge about the specific database providers. For example for PostgreSQL:
If you just want to support one database provider, you can use the database specific attribute on the base context directly.
86
+
87
+
````cs
88
+
[NpgsqlDbContext]
89
+
publicclassSolarSystemContext : MoryxDbContext
90
+
{
91
+
...
92
+
}
93
+
````
94
+
51
95
## Entities
52
96
53
97
Then you need to define your entities which will be represented as tables in your database.
@@ -126,11 +170,11 @@ You can decide between three options of tracking:
126
170
If an entity consists of one or more navigation properties you might want to have access to them.
127
171
There are three ways to access these kind of properties:
128
172
129
-
| Mode | Explanation |
130
-
|---------------------|---|
131
-
|`Eager loading`| With eager loading it is possible to configure which relations shall be loaded every time (Have a look on the [Include extension](https://msdn.microsoft.com/en-us/library/system.data.entity.dbextensions.include.aspx)) |
132
-
|`Lazy loading`| Lazy loading loads relations when you access them |
133
-
|`Explicit loading`| You can load a relation explicitly when lazy loading was turned off |
|`Eager loading`| With eager loading it is possible to configure which relations shall be loaded every time (Have a look on the [Include extension](https://msdn.microsoft.com/en-us/library/system.data.entity.dbextensions.include.aspx)) |
176
+
|`Lazy loading`| Lazy loading loads relations when you access them |
177
+
|`Explicit loading`| You can load a relation explicitly when lazy loading was turned off|
134
178
135
179
### Enable automatic lazy loading
136
180
@@ -252,63 +296,60 @@ Database migration consists of a migration configuration that is needed for ever
Forbothoptionsweneedimplementationsofthe `IDesignTimeDbContextFactory<TContext>` interfaceforevery `DbContext` youwanttomigrate ([MicrosoftDocs](https://learn.microsoft.com/en-us/ef/core/cli/dbcontext-creation?tabs=dotnet-core-cli#from-a-design-time-factory)). This factory is used by the migration tool to create an instance of your context during design time. MORYX provides a base implementation for you to make your life easier and avoid code duplication. Each database specific implementation provides a base class for you to derive from. For PostgreSQL it is the `NpgsqlDesignTimeDbContextFactory<TContext>` located in the `Moryx.Model.PostgreSQL` package. For Sqlite it is the `SqliteDesignTimeDbContextFactory<TContext>` located in the `Moryx.Model.Sqlite` package.
The `Moryx.Model.DesignTimeFactory<TContext>` baseclassesalreadyimplementthelogictoreadtheconnectionstringfromthecommandlineparametersorthe `EFCORETOOLSDB` environmentvariable.
0 commit comments