如何在VB.NET中定义entitytype的键 [英] How to define the key for entitytype in VB.NET

查看:110
本文介绍了如何在VB.NET中定义entitytype的键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i have class model like this




Public Class MenuSidebar
    Public Property ID() As Integer
    Public Property MenuCode() As String
    Public Property MenuDescription() As String
    Public Property Method() As String
    Public Property Controller() As String
    Public Property MenuInduk() As Integer
    Public Property CreatedTime() As Date
    Public Property CreatedBy() As String
    Public Property LastModifiedTime() As Date
    Public Property LastModifiedBy() As String
End Class





我尝试过:



我必须做什么?

i不知道如何定义该类模型的密钥。

在我的数据库中,我表中的键是在ID。

我必须做什么..

请帮帮我



What I have tried:

what i must to do ?
i dont know how to define the key for that class model.
in my database, the key in my table is in ID.
what i must to do..
Please help me

推荐答案

我想你是什么要问的是你需要在你的ID道具上指定Key属性erty因为EF正在寻找它而不是ID而不是ID



I think what you are asking is that you need to specify the Key attribute on your ID property as EF is looking for it to be named Id instead of ID

Public Class MenuSidebar
    <key>
    Public Property ID() As Integer
    Public Property MenuCode() As String
    Public Property MenuDescription() As String
    Public Property Method() As String
    Public Property Controller() As String
    Public Property MenuInduk() As Integer
    Public Property CreatedTime() As Date
    Public Property CreatedBy() As String
    Public Property LastModifiedTime() As Date
    Public Property LastModifiedBy() As String
End Class</key>


我建​​议你阅读:

代码优先数据注释 [ ^ ]

如何:在无推断密钥时创建实体密钥 [ ^ ]
I'd suggest to read this:
Code First DataAnnotations[^]
How to: Create an Entity Key When No Key Is Inferred[^]


这篇关于如何在VB.NET中定义entitytype的键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆