实体框架应该很简单,对吧? [英] Entity Framework should be simple, right?

查看:90
本文介绍了实体框架应该很简单,对吧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个表

创建表国家
(
ID bigint不为null,FullName nvarchar(255)不为null唯一,
约束PK_Countries_ID主键(ID)
)
转到
创建表CountryStates
(ID bigint不为空,identity(1,1),FullName,nvarchar(255),不为空,
ShortName,nvarchar(10, )null,
CountryID bigint不为null,
约束PK_CountryStates_ID主键(ID),约束FK_CountryStates_CountryID外键(CountryID)引用国家/地区(ID))
go

>我需要创建一个具有以下属性的实体
ID(映射到CountryStates.ID)
全名(映射到CountryStates.FullName)
短名称(映射到CountryStates.ShortName)
CountryID(映射到CountryStates.CountryID或COuntries.ID不论是什么开始)
CountryFullName(映射到Countrys.FullName)

链接到工作室屏幕

I have 2 tables

create table Countries
(
ID bigint not null,
FullName nvarchar(255) not null unique,
constraint PK_Countries_ID primary key (ID)
)
go
create table CountryStates
(
ID bigint not null identity(1,1),
FullName nvarchar(255) not null,
ShortName nvarchar(10) null,
CountryID bigint not null,
constraint PK_CountryStates_ID primary key (ID),
constraint FK_CountryStates_CountryID foreign key (CountryID) references Countries(ID)
)
go

I need to create an Entity that has the following properties
ID (mapped to CountryStates.ID)
Fullname (mapped to CountryStates.FullName)
Shortname (mapped to CountryStates.ShortName)
CountryID (mapped to CountryStates.CountryID or COuntries.ID Whatever for the start)
CountryFullName (mapped to Countries.FullName)

link to studio screen
http://www.avwork.com/misc/MappingScreen.jpg

The error message is on the screen.
I expect the inner join to happen when selecting CountryStates.

Why does it not compile?

于2009年7月9日(星期四)下午1点02修改
modified on Thursday, July 9, 2009 1:02 PM

推荐答案

您的链接屏幕图像不起作用.
Your link to the screen image doesn''t work.


链接对我有用.

Link worked for me.

错误3024映射片段问题.必须为所有关键属性指定映射

Error 3024 Problem in Mapping Fragment. Must specify mapping for all key properties

内部联接将是:

Country.ID = CountryStates.CountryID上的内部联接国家?

Inner Join Countries on Countries.ID = CountryStates.CountryID ?

也许映射名称问题

叫我鸡,但是我会创建一个视图并使用它.

Call me chicken but I''d create a view and use that instead.

不是Entity Framework的好用户

Not a great user of Entity Framework

干杯.


这篇关于实体框架应该很简单,对吧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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