I switched my DAL from LINQ to the Entity Framework because my applications are different depending on the current user Connects to the database, I need to periodically create datacentext dynamically and pass in the appropriate connection string. However, when I tried to make the program a unit framework connection using my old connection string, the connection failed. He complained that he did not recognize the key in the connection string as "server".
I found out that I need to do this to get the unit framework connection to work:
EntityConnectionStringBuilder entityBuilder = New EntityConnectionStringBuilder (); EntityBuilder.Provider = "System.Data.SqlClient"; EntityBuilder.ProviderConnectionString = clientConnectionString; Entitybuilder.Metadata = "res: // * / xxxxxxxxxx.csdl ..."; Institutions Institutions = New Institutions (Antibilist.testring ());
Why is this?
What is the property of metadata?
Is this going to be a problem that it is always similar to many different connections?
What can it be done? Is there a way around it?
Thanks in advance!
Update 1: Thanks for the update Randolph, but ...
I am having this problem for the whole reason, that is, I can not store the connection string in the configuration file, the connection string is dynamic This is determined by the runtime by which the user is connecting.
Here's my exact scenario: If the user is connecting, the app pulls data from Database A. If User B is connecting, then the app pulls data from Database B. Connection strings are stored in a main database, and the number is potentially infinite. Every time I add a user, then let me know the web. There is no need to go into config, not to mention the fact that it will eventually become very big!
You will find these links very informative:
Bottom line? The unit framework requires metadata to create your unit mappings.
In addition, you should consider transferring your connection information to your configuration file instead of creating it in the code. The first link will show you how to do this
Comments
Post a Comment