I've got one class library project that contains an EF model that points to a SQL Azure database. I also have another Azure WCF Web Role project that contains a WCF Data Service exposing the data in my SQL Azure DB as a OData service. Right now I have the connection string stored in the web.config of the WCF Web Role project.
What I'd like to do is make this a configuration, so move it over to the service configuration files so I can change the connection string if necessary (putting it in the web.config seems shortsighted).
The problem I'm having is how to wire the OData service up to not use the web.config connection string but instead use one from the configuration.
RoleEnvironment.GetConfigurationSettingValue(NameofSetting);
???
Related
I am trying to use SqlTableDependency in an MVC application, but I get the following error:
"Invalid object name 'sys.login_token'."
The connection string used by SqlTableDependency is correct as I also use it for the entire application.
To enable SQL SERVER Service Broker on Azure, you need to have a SQL Managed Instance Object instead of SQL Database on Azure. to more detail take a look at this link.
Consider the next scenario:
I have created an ASP.NET MVC 5 Web Application for a very simple project. The database is hosted on Azure. I have a separated project to handle the database operations. Now I want to use the Identity Framework to manage the security and authorization. In the most articles I have read there is a common solution:
Go to the ApplicationDbContext class
Change the "DefaultConnection" string by my own connection string ("SurveysEntities" in my case).
Compile and enjoy.
But in my case I am having the following exception after trying to create a new user:
The entity type ApplicationUser is not part of the model for the
current context
Considerations:
I have used the "database first" approach.
My database is hosted on Azure.
I have repplicated the database tables created on a local enviroment (localdb) but the problem persists
What is the problem?
Fix this by creating a standard connection string that pointed to the database where the ASP.NET Identity tables are (in my case the same database), used that connection string in :base.
All,
I have a ASP.NET Web API project that is making a REST call to my service layer in another project. The service project's data access is via Entity Framework 4.3. The connection string in the web.config files is set to use Integrated Security.
What is happening is, the name of the server, "server A", is being passed to the service layer, and failing authentication against SQL Server. There isn't a user account named "server A."
More specifically this is what the architecture looks like
jquery file making an api controller via POST to a method within the API controller
API controller method references the service layer DLL, and calls a method within the service class
The service class is calling a method in a repository class that uses DbContext to connect to SQl Server 2008 table.
Is there something specific I need to be doing when using the Web API framework in order to pass the correct user name down to EF?
Any help would be appreciated.
Derek
The problem is double hop impersonation. You can read about it by this link.
But i'm not sure that such impersonation is possible via REST. I recommend you use database via special account, not integrated security.
Following is the architecture of my MVC application that is built using WCF service and EF:
MVC application >> WCF Service >> Business Logic Layer >> Data access layer >> Data Store
I have created MyDbContext in Data Access layer, and it's interacting with the database.
I have created a connection string in web.config file of MVC application with the name MyDbContext. I believe this should work, but instead it is trying to create a new database on my sql server. What can be the reason? Or if I am missing anything?
If I put the connection string in web.config of WCF service, it works fine. but I believe this should be part of MVC application only, and WCF shouldn't be limited to using this connectionstring only.
If you are using WCF service to access business layer and data access layer your ASP.NET MVC application should not access the database directly - it should even don't know about database existence at all. That is the reason why you are using WCF service, isn't it? Otherwise you can delete whole your WCF service layer and call the business layer directly from ASP.NET MVC.
Connection string is not automatically transferred from MVC application through WCF call. The correct solution is to define connection string in WCF application because it is the tier where the database is accessed.
Since the WCF service is hosted in the same container which is also hosting the data access layer then it is entirely reasonable to configure it with the correct connection string.
Why would you not want to do this?
so I'm developing a SAAS application using asp.net mvc SQL server 2008 and Linq2SQL I've a master db where I'll store information about clients like name subdomain/hostname information and other stuff and I'll use one database per client for the actual client data,
what is the best way to generate and use the connection string for each individual db the connection string will be based on each customer domain so I could hard code it into master db at customer creation and create the DataContext based on that? any flaws in this strategy?
I am also using forms authentication and it will be built into each clients own db so do I've add anything dynamically to the configuration? as currently the authentication/membership is driven by connection string inside the web.config file
You should probably have a table in a centralized master db that includes the database connection information for each client. Then in your SAAS application, any time you are instantiating the data context, instead of using the default parameterless constructor, use the constructor overload that takes the connection string you stored in the centralized database for that client. The context shouldn't be kept alive between requests, so you shouldn't have a problem with cross page requests across multiple clients.