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
Copy file name to clipboardExpand all lines: src/content/docs/bff/fundamentals/session/server-side-sessions.mdx
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ The default implementation stores the session in-memory. This is useful for test
34
34
35
35
## Using Entity Framework for the Server-side Session Store
36
36
37
-
To use the EF session store, install the *Duende.BFF.EntityFramework* NuGet package and register it by calling *AddEntityFrameworkServerSideSessions*, like this:
37
+
To use the EF session store, install the `Duende.BFF.EntityFramework` NuGet package and register it by calling `AddEntityFrameworkServerSideSessions`, like this:
38
38
39
39
```csharp
40
40
varcn=_configuration.GetConnectionString("db");
@@ -67,14 +67,14 @@ Note, you'll still need to let the server side session store know about the `Ses
67
67
68
68
### Entity Framework Migrations
69
69
70
-
Most data stores that you might use with Entity Framework use a schema to define the structure of their data. *Duende.BFF.EntityFramework* doesn't make any assumptions about the underlying datastore, how (or indeed even if) it defines its schema, or how schema changes are managed by your organization. For these reasons, Duende does not directly support database creation, schema changes, or data migration by publishing database scripts.
70
+
Most data stores that you might use with Entity Framework use a schema to define the structure of their data. `Duende.BFF.EntityFramework` doesn't make any assumptions about the underlying datastore, how (or indeed even if) it defines its schema, or how schema changes are managed by your organization. For these reasons, Duende does not directly support database creation, schema changes, or data migration by publishing database scripts.
71
71
72
-
You are expected to manage your database in the way your organization sees fit. Using EF migrations is one possible approach to that, which Duende facilitates by publishing entity classes in each version of *Duende.BFF.EntityFramework*. An example project that uses those entities to create migrations is [here](https://github.com/DuendeSoftware/products/tree/main/bff/migrations/UserSessionDb).
72
+
You are expected to manage your database in the way your organization sees fit. Using EF migrations is one possible approach to that, which Duende facilitates by publishing entity classes in each version of `Duende.BFF.EntityFramework`. An example project that uses those entities to create migrations is [here](https://github.com/DuendeSoftware/products/tree/main/bff/migrations/UserSessionDb).
73
73
74
74
To quickly create Entity Framework migrations, run the following command in the project directory that has access to Entity Framework Core's tools:
75
75
76
76
```bash
77
-
dotnet ef migrations add UserSessions -o Migrations
77
+
dotnet ef migrations add UserSessions -o Migrations -c SessionDbContext
78
78
```
79
79
80
80
The project must also reference the `Duende.BFF.EntityFramework` NuGet package and the `Microsoft.EntityFrameworkCore.Design` NuGet package, along with a specific database provider and its corresponding configuration, including the connection string.
@@ -89,7 +89,7 @@ Abandoned sessions will remain in the store unless something removes the stale e
89
89
{/* prettier-ignore */}
90
90
<TabItemlabel="V4">
91
91
92
-
If you wish to have such sessions cleaned up periodically, then you can add the session cleanup host and configure the *SessionCleanupInterval* options:
92
+
If you wish to have such sessions cleaned up periodically, then you can add the session cleanup host and configure the `SessionCleanupInterval` options:
93
93
94
94
<Code
95
95
lang="csharp"
@@ -99,9 +99,9 @@ Abandoned sessions will remain in the store unless something removes the stale e
99
99
})
100
100
.AddServerSideSessions();`}/>
101
101
102
-
This requires an implementation of [*IUserSessionStoreCleanup*](/bff/extensibility/sessions#user-session-store-cleanup) in the ASP.NET Core service provider.
102
+
This requires an implementation of [`IUserSessionStoreCleanup`](/bff/extensibility/sessions#user-session-store-cleanup) in the ASP.NET Core service provider.
103
103
104
-
If using Entity Framework Core, then the *IUserSessionStoreCleanup* implementation is provided for you when you use *AddEntityFrameworkServerSideSessions*.
104
+
If using Entity Framework Core, then the `IUserSessionStoreCleanup` implementation is provided for you when you use `AddEntityFrameworkServerSideSessions`.
105
105
You can then add the `SessionCleanupBackgroundProcess`:
106
106
107
107
<Code
@@ -125,7 +125,7 @@ builder.Services.AddBff()
125
125
</TabItem>
126
126
<TabItemlabel="V3">
127
127
128
-
If you wish to have such sessions cleaned up periodically, then you can configure the *EnableSessionCleanup* and *SessionCleanupInterval* options:
128
+
If you wish to have such sessions cleaned up periodically, then you can configure the `EnableSessionCleanup` and `SessionCleanupInterval` options:
129
129
130
130
<Code
131
131
lang="csharp"
@@ -136,9 +136,9 @@ builder.Services.AddBff()
136
136
})
137
137
.AddServerSideSessions();`}/>
138
138
139
-
This requires an implementation of [*IUserSessionStoreCleanup*](/bff/extensibility/sessions#user-session-store-cleanup) in the ASP.NET Core service provider.
139
+
This requires an implementation of [`IUserSessionStoreCleanup`](/bff/extensibility/sessions#user-session-store-cleanup) in the ASP.NET Core service provider.
140
140
141
-
If using Entity Framework Core, then the *IUserSessionStoreCleanup* implementation is provided for you when you use *AddEntityFrameworkServerSideSessions*.
141
+
If using Entity Framework Core, then the `IUserSessionStoreCleanup` implementation is provided for you when you use `AddEntityFrameworkServerSideSessions`.
Copy file name to clipboardExpand all lines: src/content/docs/bff/upgrading/bff-v2-to-v3.md
+27Lines changed: 27 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -137,4 +137,31 @@ If you used `BffBlazorOptions.StateProviderPollingInterval` or `BffBlazorOptions
137
137
different polling settings, you should now consider if this same setting applies to either Server, WASM or both. Set the
138
138
appropriate properties accordingly.
139
139
140
+
### Server Side Sessions Database Migrations
140
141
142
+
No [Entity Framework database migrations](/bff/fundamentals/session/server-side-sessions.mdx#entity-framework-migrations) are required for the server side sessions feature when using the `Duende.BFF.EntityFramework` package.
143
+
144
+
The database structure remains the same:
145
+
146
+
```sqlite
147
+
// serversidesessions.sql
148
+
CREATE TABLE "UserSessions" (
149
+
"Id" INTEGER NOT NULL CONSTRAINT "PK_UserSessions" PRIMARY KEY AUTOINCREMENT,
150
+
"ApplicationName" TEXT NULL,
151
+
"SubjectId" TEXT NOT NULL,
152
+
"SessionId" TEXT NULL,
153
+
"Created" TEXT NOT NULL,
154
+
"Renewed" TEXT NOT NULL,
155
+
"Expires" TEXT NULL,
156
+
"Ticket" TEXT NOT NULL,
157
+
"Key" TEXT NOT NULL
158
+
);
159
+
160
+
CREATE UNIQUE INDEX "IX_UserSessions_ApplicationName_Key" ON "UserSessions" ("ApplicationName", "Key");
161
+
162
+
CREATE UNIQUE INDEX "IX_UserSessions_ApplicationName_SessionId" ON "UserSessions" ("ApplicationName", "SessionId");
163
+
164
+
CREATE UNIQUE INDEX "IX_UserSessions_ApplicationName_SubjectId_SessionId" ON "UserSessions" ("ApplicationName", "SubjectId", "SessionId");
165
+
166
+
CREATE INDEX "IX_UserSessions_Expires" ON "UserSessions" ("Expires");
0 commit comments