Removing existing profile providers


Q1 The book assumes that before registering a new SqlProfileProvider, we must delete all existing profile providers using the <clear> element. But:

A) why should we use <clear> instead of <remove> ?

B) I assume that root web.config or machine.config do not register (by default) any profile provider and therefore do not use the <clear> element?


Q2 I assume why each profile property does not have a corresponding column in the database table (instead, all properties are stored in one field) due to the fact that every time we add and remove profile properties, we also need to change the table layout?


thanks

0
source share
2 answers

In fact, AspNetSqlProfileProvider (of type System.Web.Profile.SqlProfileProvider ) is added by default to machine.config . Look at your C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG (or another location). However, it is not registered as a default provider. Therefore, if you are satisfied with the default settings , just use the following configuration:

 <profile enabled="true" defaultProvider="AspNetSqlProfileProvider" /> 

If you want to use a custom provider, it is usually recommended that you clear all existing providers (although this is optional) and name a different default provider.

The reason you don’t use remove is because it requires a name attribute that you may not know. Using clear removes all previously registered profile providers, using remove removes only one by name.

As for Q2, you're right. The database schema used must be sufficiently general to accommodate many different properties (and property types).

+2
source

Following RWWilden's answer , there is an available SQL table profile provider that maps properties to columns in the database:

Sample Profile Profile Table

ScottGu had a brief introduction to them here:

ASP.NET 2.0 Table Table Profiles Provider

+1
source

All Articles