I have an application which will take the server name as input and displays databases of the server connected. This means the server name can vary from user to user. I have some other dropdowns after user connected to database which needs to be populated
using the entity data source like tables, views etc. can we use the entity framework in this scenerio to populate the data, where as ado.net entity data model uses static server and database. it could be helpful for me if somebody helps me.
Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post fixed your problem.
Using the Entity Framework, your DbContext class name must match your connection string name (and that connection string must be valid) in order for the Entity Framework to work.
can we connect dynamically to the database using entity data model?
Yes, you can.
You can just change the real db's connectionn string, and do mapping from EntityFramework's models to that table.
But you should notice that you cannot change the schema of your real table, otherwises you have to re-create the edmx entity models and do mapping again.
vallamreddy1...
Member
105 Points
77 Posts
can we connect dynamically to the database using entity data model?
Dec 26, 2012 08:57 AM|LINK
I have an application which will take the server name as input and displays databases of the server connected. This means the server name can vary from user to user. I have some other dropdowns after user connected to database which needs to be populated using the entity data source like tables, views etc. can we use the entity framework in this scenerio to populate the data, where as ado.net entity data model uses static server and database. it could be helpful for me if somebody helps me.
eric2820
Contributor
2777 Points
1161 Posts
Re: can we connect dynamically to the database using entity data model?
Dec 26, 2012 01:21 PM|LINK
Using the Entity Framework, your DbContext class name must match your connection string name (and that connection string must be valid) in order for the Entity Framework to work.
http://www.my-msi.net/Admin
blog
If a post helps you, please mark it as Ansered, thank-you.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: can we connect dynamically to the database using entity data model?
Dec 27, 2012 12:41 AM|LINK
Yes, you can.
You can just change the real db's connectionn string, and do mapping from EntityFramework's models to that table.
But you should notice that you cannot change the schema of your real table, otherwises you have to re-create the edmx entity models and do mapping again.
Reguards!