(ASP.NET Membership) How do I add a new property to aspnet_Profile?

五迷三道 提交于 2019-12-24 21:25:50

问题


So I need to add two new properties to the Profile object for asp.net membership.

I added these two items to the properties tag in web.config.

<group name="Terms">
  <add name="Promotions" type="Bool" serializeAs="String" />
  <add name="AcceptedTerms" type="Bool" serializeAs="string" />
</group>

In my code behind I am able to do Profile.Terms.Promotions and call Profile.Save() with no exceptions.

However, the aspnet_Profile table does not seem to have the updated properties.

Do I need to run something on the actual database, like an update script of some sort?

Thanks in advance!

Edit by Jack:

So I found out it's an issue with my development database server. For some reason Profile info is not saving properly. So this is a whole other issue ha


回答1:


Membership profile uses it's own method of generating a serialized profile object that represents the properties you require. On objects that have already been created in the database the new properties might not be present until they have been re-saved.




回答2:


The aspnet_Profile table serializes everything as a BLOB- it doesn't add new columns. It does this because it means the DB does not need have its schema changed.

Of course you change this behaviour quite easily- here is one such article describing how to do it.



来源:https://stackoverflow.com/questions/1478906/asp-net-membership-how-do-i-add-a-new-property-to-aspnet-profile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!