473,394 Members | 1,811 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

EF EDM Designer is ticking me off... and other EF questions

#1
----
Why does VS2008 "forget" how to open EDMX files?? After opening and
closing the file a few times, double clicking on the EDMX file just ends
up expanding/collapsing the contents (the .Designer.cs file), but
doesn't actually open the file in the designer. Right-clicking the file
and clicking "Open" does absolutely nothing. Right-clicking the file
and selecting "Open With..." gives me the option to open with the
ADO.NET Entity Data Model Designer (which is default) but when I select
that, it doesn't do anything at all either. I have to close VS2008 and
reopen it to get it to work again... Anyone else seeing this?

#2
----
I'm also a bit frustrated that when I remove an entity from the design
surface, there seems to be no way to get it back other than to edit the
EDMX, remove all references to the table, and then refresh from the
database. (Yeah I guess I could manually edit it in, but that's error
prone and shouldn't be necessary.) Am I missing something?

#3
----
On a lighter note, I'm also having issues with how it handles inherited
classes, but this is probably just me needing some help in
understanding. I want to have a class derived from a base class... my
table structure looks like this:

BaseItem DerivedItem
--------- ------------
BaseItemId uniqueidentifier, PK ---- DerivedItemId uniqueidentifier, PK
BaseItemField varchar(50) DerivedItemField int

where the "----" represents a SQL relation between the two fields.

First, when I import these two tables, EDMD imports them as a relation..
ok I can understand that, although I think that default behavior if two
PKs are used should be to assume that you want inheritance. Anyway, so
I delete the relation and specify on DerivedItem entity that the base
class is BaseItem. When I do this, it sets the EntityKey property on
the DerivedItemId field to false. ummm ok. The model saves fine, but
when I Validate, I get an error... Error 3024: Problem in Mapping
Fragment starting at line 177: Must specify mapping for all key
properties (BaseItem.BaseItemId) of the EntitySet BaseItem. I've
googled this and there's a lot of talk about it, but not much of a clear
solution that I can see.

Actually, I know how to fix this... if the base class and the derived
class have the same name for the primary key, then I can work around
this issue by deleting the (derived) primary key from the derived
entity, then remapping the database column back to the (inherited)
primary key.

So my first question is... Why can't I do the same thing when the
derived class and the base class have differently named primary keys?

My second question in this scenario is... when I specify the base
entity on the derived entity, how does EDMD know that it is the
BaseItemId - DerivedItemId link that drives the inheritance? Is it just
using the previous relation? What happens if there were alternate
relations between the two tables? For example, in my real database, I
want to have an "Employee" that derives from "Person". But I also want
employee to have a relation to "Person" thru a relation that represents
the employee's emergency contact... Maybe I'm getting into scenarios
that the designer isn't up to par with yet??

-mdb
Aug 20 '08 #1
5 2101
Hi Michael. I am having same issues as #1 and #2. Looks like it is SP1v2
time.

"Michael Bray" <mb***@dontemailme.comwrote in message
news:Xn*****************@207.46.248.16...
#1
----
Why does VS2008 "forget" how to open EDMX files?? After opening and
closing the file a few times, double clicking on the EDMX file just ends
up expanding/collapsing the contents (the .Designer.cs file), but
doesn't actually open the file in the designer. Right-clicking the file
and clicking "Open" does absolutely nothing. Right-clicking the file
and selecting "Open With..." gives me the option to open with the
ADO.NET Entity Data Model Designer (which is default) but when I select
that, it doesn't do anything at all either. I have to close VS2008 and
reopen it to get it to work again... Anyone else seeing this?

#2
...

Aug 21 '08 #2
Michael Bray wrote:
#3
----
On a lighter note, I'm also having issues with how it handles inherited
classes, but this is probably just me needing some help in
understanding. I want to have a class derived from a base class... my
table structure looks like this:

BaseItem DerivedItem
--------- ------------
BaseItemId uniqueidentifier, PK ---- DerivedItemId uniqueidentifier, PK
BaseItemField varchar(50) DerivedItemField int

where the "----" represents a SQL relation between the two fields.

First, when I import these two tables, EDMD imports them as a relation..
ok I can understand that, although I think that default behavior if two
PKs are used should be to assume that you want inheritance. Anyway, so
I delete the relation and specify on DerivedItem entity that the base
class is BaseItem. When I do this, it sets the EntityKey property on
the DerivedItemId field to false. ummm ok. The model saves fine, but
when I Validate, I get an error... Error 3024: Problem in Mapping
Fragment starting at line 177: Must specify mapping for all key
properties (BaseItem.BaseItemId) of the EntitySet BaseItem. I've
googled this and there's a lot of talk about it, but not much of a clear
solution that I can see.
Heh, yes I've seen this too when I tested the EF designer with our
inheritance test db.

It's really silly that they run into this error as Nijssen/Halpin
described clearly back in 1989 in their book "Conceptual Schema and
Relational Database Design" how to formulate tables which represent an
entity inheritance hierarchy: they gave a couple of options, one being
the one you defined above.

So reverse engineering the relational model back to a model at the
entities abstraction level (similar to NIAM/ORM), is simply analysing
the model if you see these kind of relations and if so, use them for an
inheritance hierarchy. LLBLGen Pro does this automatically and I was
surprised the EF designer not only wasn't able to detect them, but
actually ran into a problem where it made life very hard for the user
who simply wanted to define the inheritance hierarchy the way it was
meant (i.e. the inheritance hierarchy which LEAD to the table setup as
you described!)

Even more ironic is that prof. Halpin was a MS employee for quite a
while. :)
Actually, I know how to fix this... if the base class and the derived
class have the same name for the primary key, then I can work around
this issue by deleting the (derived) primary key from the derived
entity, then remapping the database column back to the (inherited)
primary key.

So my first question is... Why can't I do the same thing when the
derived class and the base class have differently named primary keys?
I think they've overlooked this possibility of overriding fields
through different names. Which is odd as they don't even have the
concept of a FK field in the entity.
>
My second question in this scenario is... when I specify the base
entity on the derived entity, how does EDMD know that it is the
BaseItemId - DerivedItemId link that drives the inheritance? Is it just
using the previous relation? What happens if there were alternate
relations between the two tables? For example, in my real database, I
want to have an "Employee" that derives from "Person". But I also want
employee to have a relation to "Person" thru a relation that represents
the employee's emergency contact... Maybe I'm getting into scenarios
that the designer isn't up to par with yet??
I think that they'll pick the PK-PK relation as that's the only
relationship which can be used for inheritance. There's no other way.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Aug 21 '08 #3
I got some joy on these from Pablo:

"Issue 1: if the table is already "known" to the designer, then you don't
need to import it again. If you delete it from your conceptual model you can
re-add it by creating a new entity and mapping it to the underlying table
(in the mapping designer the table will still show up). The "update from
database" thing is usually needed when you actually changed something in the
database, or want to add something that you didn't add originally.

Issue 2: yeah, that's our bad (i.e. DateTimeOffset not supported). It's not
that we didn't catch it, actually. Because of timing issues we couldn't get
support for this data type in Astoria v1.

Issue 3: (Not able to open Model) I've seen this too in my box, but couldn't
reproduce it reliable. Do you happen to have the Silverlight tools
installed? I have a "weaking founded" theory that these two are not
interacting well..."

Aug 24 '08 #4
"William Stacey [C# MVP]" <wi************@gmail.comwrote in
news:CC**********************************@microsof t.com:
I got some joy on these from Pablo:
Who's Pablo? (Obviously I'm sure one of the EF designers, I just am
curious about the details.)
"Issue 1: if the table is already "known" to the designer, then you
don't need to import it again. If you delete it from your conceptual
model you can re-add it by creating a new entity and mapping it to the
underlying table (in the mapping designer the table will still show
up). The "update from database" thing is usually needed when you
actually changed something in the database, or want to add something
that you didn't add originally.
I think I see what he means... the problem then is that I have to map
every single field manually, unless there is a way to do this automatically
that I'm not seeing. Actually, it will do some automatic mapping - but
only of the primary keys, it appears.
Issue 2: yeah, that's our bad (i.e. DateTimeOffset not supported).
It's not that we didn't catch it, actually. Because of timing issues
we couldn't get support for this data type in Astoria v1.
Ummm... I'm not quite sure what you are referring to here... it doesn't
seem to be an answer to any of MY questions. (Perhaps you confused my
questions with someone else's question??)
Issue 3: (Not able to open Model) I've seen this too in my box, but
couldn't reproduce it reliable. Do you happen to have the Silverlight
tools installed? I have a "weaking founded" theory that these two are
not interacting well..."
Not sure, really... I don't think so. I have so much stuff loaded on my
dev box that I can't keep track of it. I know I can run Silverlight stuff,
but I don't think I have any 'tools' loaded. Don't hold me to it, though.

I haven't been able to reproduce it reliably either, but it happens often
enough that it is really annoying.

-mdb
Aug 25 '08 #5
They are looking at changing the delete/add table behavior for V2. Until
then, you have to manually add entity and columns or delete the whole model
and add new.

"Michael Bray" <mb***@dontemailme.comwrote in message
news:Xn*****************@207.46.248.16...
"William Stacey [C# MVP]" <wi************@gmail.comwrote in
news:CC**********************************@microsof t.com:
>I got some joy on these from Pablo:

Who's Pablo? (Obviously I'm sure one of the EF designers, I just am
curious about the details.)
>"Issue 1: if the table is already "known" to the designer, then you
don't need to import it again. If you delete it from your conceptual
model you can re-add it by creating a new entity and mapping it to the
underlying table (in the mapping designer the table will still show
up). The "update from database" thing is usually needed when you
actually changed something in the database, or want to add something
that you didn't add originally.

I think I see what he means... the problem then is that I have to map
every single field manually, unless there is a way to do this
automatically
that I'm not seeing. Actually, it will do some automatic mapping - but
only of the primary keys, it appears.
>Issue 2: yeah, that's our bad (i.e. DateTimeOffset not supported).
It's not that we didn't catch it, actually. Because of timing issues
we couldn't get support for this data type in Astoria v1.

Ummm... I'm not quite sure what you are referring to here... it
doesn't
seem to be an answer to any of MY questions. (Perhaps you confused my
questions with someone else's question??)
>Issue 3: (Not able to open Model) I've seen this too in my box, but
couldn't reproduce it reliable. Do you happen to have the Silverlight
tools installed? I have a "weaking founded" theory that these two are
not interacting well..."

Not sure, really... I don't think so. I have so much stuff loaded on
my
dev box that I can't keep track of it. I know I can run Silverlight
stuff,
but I don't think I have any 'tools' loaded. Don't hold me to it, though.

I haven't been able to reproduce it reliably either, but it happens often
enough that it is really annoying.

-mdb
Sep 9 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Metro Sauper | last post by:
Why is the default text representation for booleans in C# 'True' and 'False' whereas in xml it is 'true' and 'false'? It seems like it would make sense to have them both the same. Metro T....
9
by: James Geurts | last post by:
Hey all... I posted this in the vs.net ide group too, but people are not answering, so I figured that it might be more appropriate here. I'm not sure if I'm adding a designer to my code properly. ...
1
by: Sebastian Sylvan | last post by:
Hey. I have two questions. First of all I'm using the Visual C# Express Beta. When you create a windows application it will automatically split the main form into two files using partial...
0
by: sdbranum | last post by:
I have been using Visual C#.NET to code a large project having many data adapters, data sets, datagrids, multiple forms with tab pages, each containing various controls (mostly label, text boxes,...
3
by: Chris Hayes | last post by:
I'm trying to create a nifty Windows Service that will perform tasks at a predetermined interval. To make sure I understand the timing correctly I have set an emailer utility to email me on the...
6
by: Xero | last post by:
Hi. I have created a 'stop watch' program. The working principle of the program is to declare an integer (say 'intTime'), which is initalized to zero. Once the user clicks the 'Start' button,...
3
by: Phill. W | last post by:
(VB.Net 2003) I have a UserControl that exposes a number of public properties. When using this control on a.n.other Form, how can(?) I prevent the Forms Designer from adding code into...
2
by: tom | last post by:
Hello, I'm trying to do some online game that would contain similar thing to one much popular in such game.s I mean the thing when you click some option and then a timer starts and you get a...
4
by: Goran Djuranovic | last post by:
Hi all, I am experiencing a strange thing happening with a "designer.vb" page. Controls I manually declare in this page are automatically deleted after I drop another control on a ".aspx" page. -...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.