There is some Odata lib which I can use that from edmx file it generate an
odata service?
By providing only edmx file it create the service that can answer the metadata calls...
I've found this library
https://github.com/htammen/n-odata-server
But it requires json not edmx/metadata.xml file...
I see the Olingo lib but I didn't find any functionality that can do it ...
https://olingo.apache.org
Any direction if it possible?
I prefer to use some nodejs lib if there is some combination that could work, but its not mandatory
I've also find this lib
https://github.com/jaystack/jaysvcutil
If you are happy to use .Net, you could try RESTier. Follow the instructions here: http://odata.github.io/RESTier/, except don't generate a new EF data model class. Instead add your edmx model into the project.
Then go to the section 'Configure the OData Endpoint', and rather than entering:
await config.MapRestierRoute<EntityFrameworkApi<AdventureWorksLT>>(
"AdventureWorksLT",
"api/AdventureWorksLT",
new RestierBatchHandler(GlobalConfiguration.DefaultServer));
use your data model class (the class that inherits DbContext) rather than AdventureWorksLT in
EntityFrameworkApi<AdventureWorksLT>
, and change the route name and prefix to something more suitable.
There is a maven plugin from SAP:
<plugin>
<groupId>com.sap.cloud.sdk.datamodel</groupId>
<artifactId>odata-generator-maven-plugin</artifactId>
<version>3.52.0</version>
...
See documentation here https://sap.github.io/cloud-sdk/docs/java/features/odata/generate-typed-odata-v2-and-v4-client-for-java
Related
Is there a way to add my own auto generated field to domain like id and version , If yes the please guide me . provide me URL form where i can read and under stand the core concept of Grails and Domain specific language .
use install-template in the app to get all default templates:
grails install-template
after which you would be able to see /src/templates (newly created)
Modify DomainClass.groovy under /src/templates/artifacts as below:
#artifact.package#class #artifact.name# {
//according to your need
Long myId
Integer myVersion
static constraints = {
}
}
Done!!!!
Henceforth, when create-domain-class command is used to create a domain class, those fields will be auto populated.
I am not sure I am understanding your question correctly but here is the link to the web features of Grails documentation. The "Link Generation API" may be something you are asking after.
If you would like to manage ID and version than using Spring Security (plugin or full docs) or SQL features may be the direction you want to read more about.
EDIT: Try this Stackoverflow question and answer on using inheritance. Seems to be very similar to what you are asking.
You would need to write an AST transform to inject the fields you want to add automatically. The one that injects ‘id’ and ‘version’ can be found here as an example:
https://github.com/grails/grails-core/blob/master/grails-core/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/DefaultGrailsDomainClassInjector.java
You would then need to write a GORM event listener to automatically update the values of these properties. See
https://github.com/grails/grails-data-mapping/blob/master/grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/events/AutoTimestampEventListener.java
For an example of the one that updates the dateCreated/lastUpdated properties.
These can both be written in a separate Gradle/Maven project which you then reference in the dependencies of your BuildConfig.groovy file.
Has anyone else tried using the server-side component of Breeze.js in a solution with multiple Api Controllers for multiple EF Models?
I'm finding that after calling the MetaData endpoint on one context, all subsequent calls to MetaData endpoints in other contexts return the MetaData from the first context which was called, for example say I have two Api Controllers, each with their own MetaData endpoint:
public class CoreController : ApiController
{
readonly EFContextProvider<CoreEntities> contextProvider = new EFContextProvider<CoreEntities>();
}
public class FormsController : ApiController
{
readonly EFContextProvider<FormsEntities> contextProvider = new EFContextProvider<FormsEntities>();
}
Calling ~/Core/MetaData will return the JSON for the Core model, however a subsequent call to ~/Forms/MetaData will not return the Forms JSON, but instead the Core metadata is returned. If I call them in reverse I get the Forms metadata both times, this issue appears to persist until the host process is recycled.
I can confirm that I am able to access object data from both models as expected, so I doubt this is a routing issue.
Perhaps someone can tell me if there is some caching going on somewhere which I need to disable?
Regards,
Tom Tregenna
Ok, this should be fixed in Breeze 0.73.4, available either via nuget or zips on the breeze website.
You are right. I've tested this issue and this behaviour you reported happened. Putting breakpoints for each Metadata() method for the two Controllers, and using Fiddler, I concluded that this is not a routing issue. The two Controllers are using differents Context (contextProvider's property), but the first Metadata that was called is always returned. I guess this is Breeze's library issue. I've read the Breeze's documentation, but I have not found anything that could help.
There is another issue with the same symptoms. It is related to ambiguous references to the Entity Framework metadata in the connection string. I had two separate EDMX files, both of which were named Model.edmx (separate projects). When I referenced the assembly that contained the second EDMX file, the connection string below became ambiguous - the metadata files from both of the EDMX files fit the description.
metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;
I was able to resolve the issue by renaming one of the EDMX files.
An alternative solution would be to replace the asterisk with the full name of the assembly which contains the embedded metadata - there is actually a performance benefit to doing so. See the MSDN documentation covering Entity Framework connection strings for further details.
assemblyFullName
The full name of an assembly with the embedded resource. The name
includes the simple name, version name, supported culture, and public
key, as follows:
ResourceLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Resources can be embedded in any assembly that is accessible by the
application.
If you specify a wildcard (*) for assemblyFullName, the Entity
Framework runtime will search for resources in the following
locations, in this order:
The calling assembly.
The referenced assemblies.
The assemblies in the bin directory of an application.
If the files are not in one of these locations, an exception will be
thrown.
Cc716756.note(en-us,VS.100).gifNote: When you use wildcard (*), the
Entity Framework has to look through all the assemblies for resources
with the correct name. To improve performance, specify the assembly
name instead of the wildcard.
I'm working with a (.net4 / mvc3 ) solution file downloaded (from a reputable source) where a connection string exists in web.config but I don't see explicit instructions to create the database and there's no included '.mdf'. The first time I build I got a runtime error regarding lack of permissions to CREATE database. So I created a blank db and made sure the string referenced a SQL user that had .dbo/owner rights to the db just created.
But subsequent builds don't seem to execute that same initialize db script - where ever that's stored.
Where is this 'first use' convention for creating databases documented?
thx
That is a feature of Entity Framework Code First. I am not sure what you are looking for exactly, but searching for "EF Code First Initialization Strategy" might help.
For instance read this article: EF Code First DB Initialization Using Web.Config
I assume you are talking about Entity Framework, which allows you to create the database from an instance of an ObjectContext object, which is used in any of the three approaches in EF (database-, model- and code-first).
Look for a line that actually calls ObjectContext.CreateDatabase(). If one of the supported ADO.NET provides is used (SQL Server or SQL Server CE 4.0) this will generate the required SQL Statements. Assuming the classic Northwind example, you might find something like that:
NorthwindContext context = new NorthwindContext();
if (!context.DatabaseExists())
{
context.CreateDatabase();
}
If this is in fact a code-first application, "lalibi" is right about the initialization strategy which by default doesn't require you to explicitly create the database. (But my guess is, that it actually uses a statement internally very similar to mine).
I am currently using EntityFramework 4 with POCO objects. The POCO objects are located in their own .net project (project.Models). The Context is located in the DAL project (project.DAL). I have multiple other projects that I wish to use the context/models, for Example:
project.Website
project.Webservice
project.ConsoleApplication
Question:
How do I set the Context's connection string myself?
I have noticed that the Context object automatically finds the connection string in the web.config of the website if I add it there. Do I need to do something similiar for all the other projects? This seems inelegant and i think i'd rather have a way to manually configure it from my own config file or something.
Thanks!
AFrieze
You can pass a connection string as the first argument to the ObjectContext constructor. Read it from wherever you like and pass it explicitly, if that's what you want.
I am considering using xVal for validation of Entity Framework classes in a MVC application. This involves writing metadata classes as explained in details by Graham O'Neale (http://goneale.com/2009/03/04/using-metadatatype-attribute-with-aspnet-mvc-xval-validation-framework).
I am wondering if there's a way to auto generate such metadata classes using the metadata from the SQL database (for example: not null fields will have [Required] class attribute.
You could use Code Smith tool www.codesmithtools.com (there is a free version if I remember correctly)
I wrote an application that will read an existing database and then generate a Data Annotation Class for every table (excluding aspnet_* and VersionInfo).
http://pfsolutions-mi.com/Product/MetaDataClassGenerator
In EF 4, you can easily customize the code generation via a T4 template.