We actually solved this by writing a small command line tool that we call
from our pre build events. It prepares the XML file for real usage. (Don't
save the edmx file if you haven't changed anything, our your build will take
minutes each time).
Since all our ID's always are called "ID" we just do some magic for these
fields
XmlNodeList StorageNodes =
XDOC.GetElementsByTagName(@"edmx:StorageModels");
XmlNode StorageNode = StorageNodes.Item(0);
XmlNode SSDLNode = StorageNode.FirstChild;
foreach (XmlNode SSDLChild in SSDLNode) {
if (SSDLChild.Name == "EntityType") {
XmlNodeList SSDLChildNodes = SSDLChild.ChildNodes;
string TK =
SSDLChild.FirstChild.FirstChild.SelectSingleNode("@Name").Value;
foreach (XmlNode SSDLChildProperty in SSDLChildNodes) {
if (SSDLChildProperty.Name == "Property" &&
SSDLChildProperty.SelectSingleNode("@Name").Value == TK) {
SetAttribute(XDOC, SSDLChildProperty.Attributes,
"StoreGeneratedPattern", "Identity", null, ref Changed);
}
}
}
}
public static void SetAttribute(XmlDocument aDoc,
System.Xml.XmlAttributeCollection aCollection, string aAttribute, string
aValue, string aNameSpace, ref bool aChanged) {
foreach (System.Xml.XmlAttribute a in aCollection) {
if (a.Name.Contains(aAttribute)) {
if (a.Value == aValue) return;
aCollection.Remove(a);
break;
}
}
XmlAttribute xa;
if (!string.IsNullOrEmpty(aNameSpace)) {
xa = aDoc.CreateAttribute(aAttribute, aNameSpace);
} else {
xa = aDoc.CreateAttribute(aAttribute);
}
xa.Value = aValue;
aCollection.Append(xa);
aChanged = true;
}
-----Original Message-----
From: sasha [mailto:[email protected]]
Sent: donderdag 2 juli 2009 14:09
To: [email protected]
Subject: Re: [Firebird-net-provider] Generated primary key columns in EF
> as there's no way in FB to know that the PK column is autogenerated
> using generator (at least I don't), you have to tweak the model to set
> this up. Unfortunately every update of model will remove this. I'm
> thinking about some special mark (anywhere) in comment to let me know
> to mark this as generated PK column. What do you think?
>
> What about "#PK_GEN#"?
I think that:
1) This question should be discussed in fb-devel and i think that new
feature should be added to server for this
2) I think that special table will be better solution than comments
3) Have you thought about views? There are big problems with views too,
because provider dont't know abbout any relations, key fields and
autoincrements for wiews.
So, i'd like to propose to make some special tables like this:
_AUTOINCREMENTS (FIELD_NAME, GENERATOR_NAME)
_VIEW_PRIMARY_KEYS (VIEW_NAME, FIELD_NAME)
_VIEW_FOREIGN_KEYS (VIEW_NAME, FIELD_NAME, REFERENCE_RELATION,
REFERENCE_FIELD_NAME)
----------------------------------------------------------------------------
--
_______________________________________________
Firebird-net-provider mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
------------------------------------------------------------------------------
_______________________________________________
Firebird-net-provider mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider