What Provider DLL does the EntityConnection use to create its StoreConnection - oracle

I setup an object context like this:
public MyObjectContext(....) : this(contextName, new EntityConnection(connectionString))
The connection string is a connection string to an Oracle database. I use DevArt as a provider btw.
Everything works fine. I can use it to retrieve entities etc.
But then I wanted to do something with the underlying connection. I did something like:
(OracleConnection)((EntityConnection)context.Connection.StoreConnection)
Which gives me the following exception:
SystemInvalidCastException: [A]Devart.Data.Oracle.OracleConnection cannot be converted to [B]Devart.Data.Oracle.OracleConnection. .... Type A is from C:\Windows\....\6.60.283\.... Type B is from C:\DevDirectory\...\7.2.104.0
It seems that the ObjectContext uses an old version of the DLL. However if I check the references of my project I see a reference to the correct version 7.2.104.0. As I checked further the ObjectContext can still connect even if I have no reference at all in the Subproject where its class is.
How does it resolve the DLL it uses to connect?

Yeah I just realized that I still had the wrong version (6) of devArt installed (globally) but referenced the right version (7) in the project. The assembly containing the ObjectContext had no reference so it needed to get the version from the GAC which was the old one (6).
Thx. For the clarification.

Related

Bridge RESO OData API

Im trying to use the OData Connected Service in Visual Studio to connect to a OData Feed in Bridge (RESO Feed).
However, If I try and pull the metadata directly from a URL, it has errors Adding OData Connected Service to the project failed: Could not get CLR type name for EDM type 'memberMediaEnums.ResourceName'
So I went ahead and downloaded the XML file and tweaked it to get rid of the errors and warnings. This includes Removing Entity references with no parents and removing attributes that were not supported like Precision.
Once its all loaded and the reference file is created I tried pulling data. The endpoint works and data is retrieved, but it is not thrown into the object as i would expect.
IEnumerable<Property> properties= await context.Property.ExecuteAsync();
foreach (var property in properties) //Errors trying to make a property
{
Console.WriteLine("{0} {1}", property.YearBuilt, property.ListPrice);
}
When I try and loop over the object I get this error:
The context URI 'https://api.bridgedataoutput.com/api/v2/OData/imls2/$metadata#Property' is not valid for the expected payload kind 'Resource'.
Where I am confused, is in the name Resource There is no object or entity in the Reference file or in the XML scheme that references that word. I'm not sure if its coming from OData services or the reference file it created. The call stack does not contain anything but the exact line of the loop.
Any insights would be helpful but i know its a long shot. Let me know if I need to provide more details.
Thanks

MiniProfiler and SqlMembershipProvider

I am trying to get any DB queries that happen when using the SqlMembershipProvider to show in MiniProfiler but I can't think of any way to swap out the SqlConnection is uses with a ProfiledDbConnection as it seems to do everything internally. Anyone have any ingenious ideas?
You could download the source (freely avaliable) for the ASP.Net SQL Providers here, read more about it here, Scott Gu published tons of whitepapers in this article about the provider model.
internal to the assembly is a SQLConnectionHelper that you can update to use the ProfiledDBConnection instead. This would give profiling to all the providers using that class, all thats left is to change your .config file to use the new provider instead.

How to hide connectionStrings on Github for both Entity Framework and Membership, that will be used on AppHarbor later on?

I know the title looks somewhat confusing so let me explain. :)
I have a MVC 3.0 Project for which I maintain a public repository # github, and said Project utilizes the Entity Framework and the Membership Provider (so that's two separate connectionStrings) .
The issue I am having is that the "Alias" attribute of Sequilizer for the MS SQL database, let's me specify only one connectionString value to be replaced at build time. Because I can not modify web.config programmatically (and web.config transformations are not applicable because it will leave my sensitive data open to the World on the public github repo), I am left to choose which I want to use more -> Entity or Membership (the other solution would be leaving one of my connectionStrings vulnerable) .
Due to the need of MembershipProvider to know the connectionStringName at build time (everything is specified in web.config), I am kinda at a loss of how to go about all this.
Any help is appreciated!
Cheers
Okay guys, I think I set up everything finally.
What I did is, I used the Alias only for my normal connection string which will provide Membership stuff - while I overrode the ObjectContext default constructor (in "MyProjectEntities.Designer.cs") to use Configuration Variable (named "EntityFramework") that I set up on AppHarbor which holds the Entity Framework connectionString like so:
public MyProjectEntities() : base(ConfigurationManager.AppSettings["EntityFramework"].ToString(), "eTestHubEntities")
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}
Tested and works as I wanted it to work. :)

InnerException {"Invalid object name 'dbo.Users'"}

I am currently trying to setup an ASP.Net MVC 3 Application for the first time. I know what I am doing with Ruby on Rails but completely lost with ASP.Net. I would like the app to create the database but not sure what I am doing wrong. I have an empty Database build called ssDB. I have setup the connectionStrings and built out the Model classes. According to everything I have read thus for, when I go to the run the App it should create the database but it doesn't look that way.
The Abbreviated Error I get is:
InnerException: System.Data.SqlClient.SqlException
Message=Invalid object name 'dbo.Users'.
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060
Class=16
LineNumber=1
Number=208
Procedure=""
Server=TESTSVR01
State=1
I have an empty Database build called ssDB
You have created an empty database with no tables. Since there is a database EF assumes tables are also created. Hence it will not proceed to create the tables.
You can drop the database and allow EF to create the database and the tables.
I also experienced the same issue while using Database first approach. Connection string in my service's/service's host web.config was incorrect. I corrected the connection string and it worked.

InvalidCastException using ODP 9 with Fluent NHibernate

We're getting started with plugging in (Fluent) NHibernate 2.1.2 onto a legacy ASP.NET application.
Previously we've been connecting to an Oracle 9 database using System.Data.OracleClient, but because of some requirements (namely with using Oracle SPs with HBM maps), it seems that at least for the NH component, we'll have to adapt the Oracle.DataAccess.dll instead.
For the most part, we've managed to get that bit working by doing the following:
Adding and referencing the 9.2.0.700 Oracle.DataAccess.dll into the data layer.
Qualifying the Oracle.DataAccess assembly via the web.config. [via]
Adding OraOps9.dll into the application, and setting it to Embedded Resource.
The last step, we've done because our version of the ODP references it, but we have limited capacity to make sure that it will be present on the production server eventually.
This eventually led to getting an InvalidCastException:
Unable to cast object of type
'Oracle.DataAccess.Client.OracleConnection'
to type
'System.Data.Common.DbConnection'
Sifting around for a solution, the status quo seemed to be to ensure that the hbm2dll.keywords property in the NH configuration was set to none. I've done that in both a dynamically created config, and the fluent call to create a SessionFactory.
NHibernate.Cfg.Configuration cfg =
new NHibernate.Cfg.Configuration()
.SetProperty("dialect", "NHibernate.Dialect.Oracle9iDialect")
.SetProperty("connection.driver_class", "NHibernate.Driver.OracleDataClientDriver")
.SetProperty("connection.connection_string",conn)
.SetProperty("connection.provider","NHibernate.Connection.DriverConnectionProvider")
.SetProperty("hbm2dll.keywords","none")
;
_sessionFactory = Fluently.Configure(cfg)
.Database ( OracleDataClientConfiguration.Oracle9.ConnectionString(conn) )
.Mappings ( x => x.FluentMappings.AddFromAssemblyOf<MyDL>() )
.Mappings ( x => x.HbmMappings.AddFromAssemblyOf<MyEntity>() )
.ExposeConfiguration(x => x.Properties.Add("hbm2dll.keywords", "none"))
.BuildSessionFactory()
;
But even so, I still get the same InvalidCastException.
Is there anything else that could be causing this? Are any of my calls above accidentally tripping the hbm2dll.keywords property value back to something else? Any ideas?
ODP 9 is WAY too old and IIRC it's compiled against .NET 1.1.
You need to use ODP 10 at least.

Resources