ASP.NET 实体框架指南

发布于 2024-10-05 02:07:14 字数 382 浏览 0 评论 0原文

使用我生成的实体框架。我在默认系统 AspNetSqlRoleProvider 安全设置期间创建了一个角色表。

在 Roles 表中,我有一个 ApplicationId uniqueidentifier 列。其中填充了一个 guid,这对于我的应用程序来说不会改变。

我需要使用实体框架通过我的应用程序手动添加角色。但是,在创建我的 Roles 对象并设置 Roles.ApplicationId 时。它需要一种 Guid。我的 web.config 应用程序设置中有 ApplicationId。因为它不应该改变。但它是以字符串形式返回的。我无法键入强制转换值以在 Roles.ApplicationId 中使用。

尝试使用 EF 手动创建新角色时,如何使用当前的 ApplicationId 值?

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 uniqueidentifier 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

分分钟 2024-10-12 02:07:14

您必须转换为 Guid,但这很容易做到。构造函数采用 GUID 形式的字符串值(new Guid("..")),或者我认为也可能有一个 Parse 方法。

HTH。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文