ASP.NET Entity Framework Guid
Using the Entity Framework that I generated. I have a Roles table created during the default system AspNetSqlRoleProvider security set-up.
In the Roles table, I have an ApplicationId uniqueidentifi开发者_运维知识库er column. Which has a guid populated in it, which doesn't change for my application.
I need to add a Role manually through my app using the entity framework. However, when creating my Roles object and setting Roles.ApplicationId. It expects a type of Guid. I have the ApplicationId in my web.config app settings. As it shouldn't change. But it is returned at string. I cannot type cast the value either to use in Roles.ApplicationId.
What can I do to use my current ApplicationId value when trying to create a new role manually using the EF?
You're going to have to convert to a Guid, but that's easy to do. The constructor takes a string value that's the GUID form (new Guid("..")), or I think there may be a Parse method too.
HTH.
精彩评论