I published my Azure Mobile Service and suddenly I got this error. I use a code first approach and I have not changed my models.
"message": "An error has occurred.",
"exceptionMessage": "Unable to load the specified metadata resource.",
"exceptionType": "System.Data.Entity.Core.MetadataException",
"stackTrace": " at System.Data.Entity.Core.Metadata.Edm.MetadataArtifactLoaderCompositeResource.LoadResources(String assemblyName, String resourceName, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)\r\n
I m using EF 6.1.1 and my connection string is defined for the System.Data.SqlClientProvider.
It works fine when I run locally against my MSSQLLocalDB.
Anyone knows why EF attempts to load a Metadata even if I am using a code first approach? What should I do to troubleshoot the issue?
I found it, it was my connection string which was modified when the code was built in release environment. This issue was caused by a refactory.
Related
I am using web service consumer in Mule4 and after configuration and deployed the application and triggered the target ARIBA SOAP service in logs I see below error:
org.apache.cxf.binding.soap.SoapFault: Error reading XMLStreamReader: Undeclared namespace prefix "soapenv"
at [row,col {unknown-source}]: [1,14]
When i explored the error I see it is an issue at target system end:], please let me know whether it is end system thrown error or any pointers on what would cause this issue
enter link description here
The link you shared seems pretty clear. It is an issue on SAP Ariba side. The solution is also shared in the same page:
The error message is as follows:
<fault xmlns="http://www.bea.com/wli/sb/context">
<errorCode>OSB-380001</errorCode>
<reason>java.lang.RuntimeException: javax.xml.soap.SOAPException: Error parsing
envelope: most likely due to an invalid SOAP message.: Undeclared namespace prefix
"soapenv" at [row,col {unknown-source}]: [1,14] </reason>
For some reason Ariba doesn't seem to be declaring the SOAP XML namespaces in its responses.
If you receive the invalid soap message response error or some other invocation error from Ariba, you must enable the following property in the Ariba sand box.
Application.Messaging.Channels.Util.IncludeNameSpaceDetailsInErrorResponse
You have to follow the instructions to configure Ariba to include the namespaces in responses.
Short description:
I'm trying to create a WFC data service that will use entity framework to retrieve data from db. The important thing is that the service must be hosted inside sharepoint server. Everything (almost) is ok except that when I'm trying to access deployed service from sharepoint I've got an exception:
The server encountered an error processing the request. The exception message is 'The type initializer for 'System.Data.Services.Providers.PrimitiveResourceTypeMap' threw an exception.'. See server logs for more details. The exception stack trace is:
at System.Data.Services.Providers.PrimitiveResourceTypeMap.get_TypeMap() at System.Data.Services.Providers.ObjectContextServiceProvider.PopulateMetadata(ProviderMetadataCacheItem metadataCacheItem) at System.Data.Services.Providers.BaseServiceProvider.LoadMetadata(Boolean skipServiceOperations) at System.Data.Services.Providers.EntityFrameworkDataService1.CreateInternalProvider(Object dataSourceInstance) at System.Data.Services.DataService1.CreateMetadataAndQueryProviders(IDataServiceMetadataProvider& metadataProviderInstance, IDataServiceQueryProvider& queryProviderInstance, Object& dataSourceInstance, Boolean& isInternallyCreatedProvider) at System.Data.Services.DataService1.CreateProvider() at System.Data.Services.DataService1.HandleRequest() at System.Data.Services.DataService`1.ProcessRequestForMessage(Stream messageBody) at SyncInvokeProcessRequestForMessage(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
The same service hosted from normal web app works fine.
Is there anyone that had similar issue and has some clues?
I managed to create fully functional WCF data service hosted inside SharePoint 2013 on premise. I got the exception mentioned in question (as well as many others).
By fully functional I mean that my odata requests with filters from CSOM and java script are properly executed and (auto-magically) results in properly formed queries to SQL server database. Works both http and https.
Here is short description what is necessary to have it all working.
A bunch of dll from nuget needs to be deployed to GAC via SharePoint WSP (here is list which worked for me)
a. EntityFramework.dll 6.1.3 for .Net 4.5
b. EntityFramework.SqlServer.dll 6.1.3 for .Net 4.5
c. Microsoft.Data.Edm.dll 5.6.2
d. Microsoft.Data.OData.dll 5.6.2
e. Microsoft.Data.Services.dll 5.6.2
f. Microsoft.Data.Services.Client.dll 5.6.2
g. Microsoft.OData.EntityFrameworkProvider.dll 1.0.0-beta2
h. System.Spatial.dll 5.6.2
Note: The trick is that there is no direct error that some of these dll’s are missing. The exception from question is displayed when there was no System.Spatial.dll in GAC.
Service should look similar to above:
using System.Data.Services;
using System.Data.Services.Providers;
using System.ServiceModel.Activation;
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class yourService : EntityFrameworkDataService<YourEntities>
{
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
config.DataServiceBehavior.MaxProtocolVersion = System.Data.Services.Common.DataServiceProtocolVersion.V3;
}
}
Svc file: YourService.svc should be deployed to dedicated feature folder inside ISAPI SP folder
For http – fragment:
<service behaviorConfiguration="WCFServicesBehavior" name=" Namespace.yourservice ">
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
For https: like in http but use mexHttpsBinding binding
Open your endpoint in browser to check if this is working
http://yoursite.local/_vti_bin/name_of_your_feature/yourservice.svc - should return info about service
http://yoursite.local/_vti_bin/name_of_your_feature/yourservice.svc/Name_of_your_entitySet() – should return all entities of given type
Check in SQL Server Profiler if your odata filters are properly translated to SQL queries
I am building a project using "Maven".
In the Pom.xml i have added dependency for Postgresql and it is downloaded (as required) and is present in the Project's libs/ folder.
Now i have made a connection to it in my java file as follows :
static String userid="postgres", password = "myPassword";
static String url = "jdbc:postgresql:coredb_jfeed6";
static Connection con;
con = DriverManager.getConnection(url,userid, password);
Where "coredb_jfeed6" is my database name.
There is no compile time error. But at runtime it produces the following error :
Exception stack is:
1. No suitable driver found for jdbc:postgresql:coredb_jfeed6 (java.sql.SQLException)
java.sql.DriverManager:640 (null)
Could not get JDBC Connection; nested exception is java.sql.SQLException: No suitable driver found for jdbc:postgresql:coredb_jfeed6
(org.springframework.jdbc.CannotGetJdbcConnectionException)
org.springframework.jdbc.datasource.DataSourceUtils:80 (null)
Root Exception stack trace:
java.sql.SQLException: No suitable driver found for jdbc:postgresql:coredb_jfeed6
at java.sql.DriverManager.getConnection(DriverManager.java:640)
at java.sql.DriverManager.getConnection(DriverManager.java:169)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:173)
Could anyone please help me regarding this.?
Ok. I figured it out.
Its a BUG in Mule 3.1.2.
Its like "When an external library is to be searched, then Mule looks it in projects/lib folder. But this does not hold true for All the Database related Libraries like postgresql library" . So we need to put it in mule/user/lib folder for it to Work Correctly.
I have a ASP.NET MVC 2 project.
I've created edmx file on the class library project that holds the model.
now I've created another class library called it shared and moved the edmx file over there.
resolved some issues, everything compiles, but it can't find the connection string resource at runtime.
I've copied the ConnectionString part of the Web.Config to the main file, the old class library app.config file and the new class library app.config file.
Still get this error:
System.Data.MetadataException: Unable
to load the specified metadata
resource.
Line 75: public myProjdb() :
base("name=myProjdb", "MyProjdb")
in the MyProj.Designer.cs file.
Any Idea how to resolve this issue ?
Is there a better way to store connection string data ?
You should be able to use the same model in other projects if you use a connection string that includes the assembly name. In the connection string you have in web.config, try changing the * in the connection string, from
metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=...
to something like this:
metadata=res://ClassLibrary1/Model1.csdl|res://ClassLibrary1/Model1.ssdl|res://ClassLibrary1/Model1.msl;provider=System.Data.SqlClient;provider connection string=...
I have been using Entity Framework CTP with Code-First as in this tutorial by Scott Guthrie and another by Scott Hanselman (can't post the link, but google "Simple Code First with Entity Framework 4 - Magic Unicorn Feature CTP 4"). This is working perfectly for the main MVC application, but I am now trying to add a testing project, that uses a separate SQL CE Database.
I have added the following to the App.Config file:
<connectionStrings>
<add name="MyData"
connectionString="Data Source=D:\myProject\myDb.sdf;"
providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
However when I try to run the tests it throws the following error when trying to create the database:
Test method
MyProjet.Tests.Administration.ModlelTests.Business.TestGetBusinessesList
threw exception:
System.Reflection.TargetInvocationException:
Exception has been thrown by the
target of an invocation. --->
System.TypeInitializationException:
The type initializer for
'System.Data.SqlServerCe.SqlCeProviderServices'
threw an exception. --->
System.Security.VerificationException:
Operation could destabilize the
runtime.
With the following stack trace:
System.Data.SqlServerCe.SqlCeProviderServices..ctor()
System.Data.SqlServerCe.SqlCeProviderServices..cctor()
System.RuntimeFieldHandle.GetValue(RtFieldInfo
field, Object instance, RuntimeType
fieldType, RuntimeType declaringType,
Boolean& domainInitialized)
System.Reflection.RtFieldInfo.InternalGetValue(Object
obj, Boolean doVisibilityCheck,
Boolean doCheckConsistency)
System.Reflection.RtFieldInfo.InternalGetValue(Object
obj, Boolean doVisibilityCheck)
System.Reflection.RtFieldInfo.GetValue(Object
obj)
System.Data.SqlServerCe.ExtensionMethods.SystemDataSqlServerCeSqlCeProviderServices_Instance_GetValue()
System.Data.SqlServerCe.ExtensionMethods.SystemDataSqlServerCeSqlCeProviderServices_Instance()
System.Data.SqlServerCe.SqlCeProviderFactory.System.IServiceProvider.GetService(Type
serviceType)
System.Data.Common.DbProviderServices.GetProviderServices(DbProviderFactory
factory)
System.Data.Common.DbProviderServices.GetProviderServices(DbConnection
connection)
System.Data.Entity.ModelConfiguration.Internal.Configuration.CodeFirstCachedMetadataWorkspace.GetMetadataWorkspace(DbConnection
storeConnection)
System.Data.Entity.Infrastructure.DbModel.CreateObjectContext[TContext](DbConnection
existingConnection)
System.Data.Entity.Internal.LazyInternalContext.InitializeFromModel(DbModel
model)
System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
System.Data.Entity.Internal.InternalContext.Initialize()
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type
entityType)
System.Data.Entity.Internal.Linq.EfInternalQuery1.Initialize()
System.Data.Entity.Internal.Linq.EfInternalQuery1.Include(String
path)
System.Data.Entity.Infrastructure.DbQuery`1.Include(String
path)
MyProjet.Areas.Administration.Models.BusinessModel.GetBusinesses()
in
D:\projects2010\MyProjet\MyProjet\Areas\Administration\Models\BusinessModel.cs:
line 47
MyProjet.Tests.Administration.ModlelTests.Business.TestGetBusinessesList()
in
D:\projects2010\MyProjet\MyProjet.Tests\Administration\ModlelTests\Business.cs:
line 45
I have tried replacing the existing MyData connection string in the MVC application, and it works fine. It only causes this problem when this is added to the Testing project. Additionally the testing project works without problem when pointed at an SQL or SQL Express Database.
Have been struggling with this for a while now, and just can't figure it out. I am sure I have overlooked something simple.
Try using
Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");
See my blog post for an example http://www.arrangeactassert.com/code-first-entity-framework-unit-test-examples/
I have been running the tests under the Built in Microsoft testing framework. Changing the test framework to NUnit (as in Jag's tutorial) has fixed the problem.
So looks like there is a conflict between SqlServerCe and the Visual Studio Unit Testing Framework.