I am working with a c#, program with entity framework. I noticed that after I updated the model from the database to pick up a few updates, my connection string is different. I'm not clear on what I did that caused it to change.
It used to look like this: "metadata=res:///;
now it is:"metadata=res:///Model.namexx.csdl|res:///Model.namexx.ssdl|res:///Model.namexx.msl;
I haven't made any other updates to the program.
I'm sorry for not being clear. I was just trying to understand why the metadata information contains information about csdl, ssdl and msl. - thank you
Thank you
Maggie
Related
I'm trying to create a datamodel in the Oracle Data Modeler module that is available in Oracle SQL Developer. I would like to maintain my data dictionary from this model. To do this (I think) I need a generated DDL file for which the attributes are not longer than 30 characters.
I have just discovered Oracle SQL Developer and am completely new to creating these kind of models. What I have done so far. I have created a logical model and have engineered it to a relational model. From the relational model I can then generate DDL scripts that I can run on the database to make the changes I want.
When doing this I run into a problem. When engineering the logical model to a relational model I can see that the foreign keys I have made become more than 30 characters. This is because it seems to generate the name as (see picture)
From searching it seems you should be able to fix this with naming standard templates. I have looked for this menu option but can't find it. I have found the name abbreviations functionality for which you can upload .csv files but I think this is for something different.
Rightclicking on the logical model in the datamodeler browser view gives me the opportunity to Apply naming standards, but this gives me a message that I should turn off the keep as the name of the originating attribute option (see picture). I have looked for this but can't find this option.
My version of Oracle SQL Developer is 4.1.3.20, Build MAIN-20.78.
Please let me know if my story is not clear. Thanks.
Generated column name
Applying name standards message
You will find the option under Tools/Preferences/Data Modeler/Model/Logical
This is actually reposting a question that already exists but I don't think it was properly understood and for us is really important to know if is possible or if it will be:
https://stackoverflow.com/questions/16079703/how-would-one-go-with-saving-a-complex-object-graph-as-xml-in-sql-database-whil
So, what we would like to know is how do we get to transfer from Breeze to server NON MAPPED TO DB entities/properties. For example, let's consider XML (I would't want to generate xml in JS, but I do have XML db columns that need to be populated from complex forms - so we will collect the data in Breeze/KO, will transfer it to server and on server will process and generate the XML, from the NON MAPPED Entities/Properties).
P.S.
I see there is already a NODB approach (http://www.breezejs.com/samples/nodb), so would be really nice if we would be able to make the 2 approaches work together (EF + NODB)
As of Breeze v 1.3.6, there is now an EntityInfo.UnmappedValuesMap property available during the save that exposes all of the unmapped properties on any entity being saved.
Providing I'm understanding your question correctly, any properties declared as 'unmapped' on a breeze entity do get transferred to the server on a save for exactly this purpose. You can intercept and work with this data within the server side BeforeSaveEntity and BeforeSaveEntities methods.
There is more info here regarding "unmapped" properties:
http://www.breezejs.com/documentation/extending-entities
The method - Entity Framework Code-First - looks good. But its very difficult to create all the classes for a large database.
Is there any easy way to generate the Entity Framework Code-First classes?
You can use the recently released Entity Framework Power Tools CTP1. The tool gives you the ability to reverse engineer code first, meaning the Database will be mapped to Code.
Note that all tables in your large database will be mapped. There currently is no way to choose which tables will be mapped to code. Reading through the comments, this feature will most likely be implemented in a future release.
The point of EF Code-First is that you define your domain model in code, then your user-interface and database can be easily generated from that domain model. This has a number of advantages including reducing the amount of tedious code which needs to be written, and helping to ensure your database, your domain model, and your UI match each other.
However, at some point you are going to have to write your domain model - there's no way that can be "generated" (by which I assume you mean computer-generated) as it is personal to your application.
If I've misunderstood your question, please leave a comment and I'll update my answer.
If you want to use the code-first model, but already have an existing database, you can use the Entity Framework Power Tools to generate classes.
If you're reading this after May/2012, the above tool may be out of beta!
No there is no way to generate classes for you if you are using code-first. Code first means that there is no model and no database so you can't generate classes unless you have some upfront design in any case system (UML) which will autogenerate code for you. Simply generating classes without any input about how they should look like sounds like AI from Sci-fi, doesn't it?
If you already have databse you are not using code first but database first. In such case you can have your classes generated.
Check out the link below. It's a program that will generate POCO classes from your databases. I think that's what you're looking for.
http://msormcodegen.codeplex.com/
Generate the code from the database first using database first generation and then modify the resulting code to start your code first version
I am using the EntityFramework POCO adapter and since there are limitations to what microsoft gives access to with regards to the meta data, i am manually extracting the information i need out of the xml. The only problem is i want to get the ssdl, msl, csdl file names to load without having to directly check for the connection string node in app.config.
In short where in the ObjectContext/EntityConnection can i get access to these file names?
Worst case scenario i need to get the connection name from the EntityConnection object then load this from app.config and parse the string itself and extract the filenames myself. (But i obviously don't want to do that).
Thanks
I can think of two ways to use reflection here:
Dig into the EntityConnection. The connection string should be in there somewhere as a private variable.
The EDM metadata files are embedded in the assembly as resources by default. You should be able to reflect the assembly that contains the EDM and pull the files out directly. Use Reflector on your assembly that contains your EDM and you should see the embedded msl, ssdl, an csdl.
I think option 2 is more robust overall.
Have you looked at the ObjectContext.MetadataWorkspace? It's not the easiest library to work with, but I was able to get all of the information that I needed.
Julia Lerman has a good chapter on the subject in her EF book.
You can refer to this post of mine.
It is not the case that, someone will be able to generate perfect Entities from the database tables every time.
If any entity is not looking perfect, how can I tweak it? And how should I tweak it?
Or should I search for the flaw of relations in the Database, fix it first and then try to generate Entities over and over again until the desired entity is generated?
But it may happen that, I would become unable to figure out the reason of an imperfect entity being generated only looking at the database tables.
You should clarify your requirements: should be everything created automatically from database or you allow hand-made updates or will do it manually (once automatically then only manual updates).
Remember, that from time to time after db structure changes you will have to generate entities again, then you may lost your changes. Consider using partial classes, so some of your code changes could be persistent across automatic generations.
But in your case let's try to figure out how how the MS has prepared the demo database and try to follow the rules. Maybe you would like to read some database design guides?
More details about your environment could help with more precise answer.
We generate the EF model based on the database. When the database changes we refresh the model. This works fine for us.
It is only if you are doing something special that you need to tweek your entities.