简体   繁体   English

C#实体框架

[英]C# Entity Framework

I am trying to create an entity for a SQL Server view. 我正在尝试为SQL Server视图创建一个实体。

I am trying to add the [ToTable] from my entity class as I am going to include it as a DbSet . 我试图从我的实体类中添加[ToTable] ,因为我将其包含为DbSet

I'm using [ToTable] and getting an error message type and namespace for ToTable not found. 我正在使用[ToTable] ,但未找到ToTable的错误消息类型和名称空间。

What would be the namespace for [ToTable] while adding to the class? 添加到类中时, [ToTable]的名称空间是什么?

ToTable() is the fluent api version ( https://msdn.microsoft.com/en-us/data/jj591617.aspx#2 ). ToTable()是流畅的api版本( https://msdn.microsoft.com/zh-cn/data/jj591617.aspx#2 )。 For annotations you want 对于您想要的注释

[Table("databaseName"]
public class ClassName...

From System.ComponentModel.DataAnnotations.Schema; 来自System.ComponentModel.DataAnnotations.Schema; https://msdn.microsoft.com/en-us/data/gg193958.aspx?f=255&MSPPError=-2147217396 https://msdn.microsoft.com/zh-cn/data/gg193958.aspx?f=255&MSPPError=-2147217396

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM