Hi,
I have used reading and writing of models from and to file in the previous release. This seems to be changed heavily in the June release. I am trying to figure out how to change this to work with the June release, but it would be most helpful if anyone already has some samples.
I am trying to setup a Store thourgh store.LoadDomainModels() method, but run into a
"Microsoft.VisualStudio.Modeling.DomainDataNotFoundException"
Jos Warmer

Reading and writing models in June release?
ssrsnewbie
jesc,
I found the SerializationHelper.LoadModel and do use it. However, this operation takes a Store as an argument and I am trying to initialize the Store before passing it to the LoadModel method.
My code is as follows:
public DtoModel LoadDtoModel(String fileName) { Store store = new Store(); Type[] modelTypes = new Type[] { typeof(Ordina.DataContract.Designer.Ordina_DataContract_Designer) }; store.LoadDomainModels(modelTypes); return Ordina_DataContract_DesignerSerializationHelper.LoadModel(store, fileName, null); }CLearlyDotNet
jayoscar
AndreasE
I did some more experimenting and found the following:
- If i add Microsoft.VisualStudio.Modeling.Diagrams.CoreDesignSurface to the types array for initalizing the store, the first exception disappears. In the previous release there were several more domain model that needed to be added, but this seems to be the only one left.
- the reading of the model must be within a Transaction, this is new, because it did not need to be inside a transaction in the previous release. When I put the reading inside a transaction the second exception dissappears.
public DtoModel LoadDtoModel(String fileName) { DtoModel result = null; Store store = new Store(); Type[] modelTypes = new Type[] { typeof(Microsoft.VisualStudio.Modeling.Diagrams.CoreDesignSurface), typeof(Ordina.DataContract.Designer.Ordina_DataContract_Designer) }; store.LoadDomainModels(modelTypes); using (Transaction t = store.TransactionManager.BeginTransaction("Reading diagram")) { result = Ordina_DataContract_DesignerSerializationHelper.LoadModel(store, fileName, null); t.Commit(); } return result; }This code does read the model ok.
Thanks for your help,
Jos Warmer
Bj&#248&#59;rnar S.
Jos
You have to load the domain models in the correct order: if B depends on A, load A first. That might be causing the problem you see.
-- Steve