I created a basic MVC app to do CRUD operations on database tables. I'm using Entity Framework Database First, so I was able to just scaffold out controllers and views very quickly.
We have a dev, qa, and prod database. The schema should be identical with only the data in each being different.
I want to create a dropdown that will let me change the connection string from the app. I'm not sure the best way to do this. It currently works just fine using the dev connection string, but if I manually change the database to qa from web.config, whenever I try to create or update an existing record from the app, I get this error:
"The UPDATE permission was denied on the object"
I don't get this error using the dev database.
The problem is with your database permissions.
Use the following link and go through the security/permissions and you will be able to solved the problem.
http://blog.sqlauthority.com/2012/04/23/sql-server-introduction-to-sql-server-security-a-primer/
Please verify that your user has the same permissions on qa/prod as it does in dev.
Related
I am using entity framework 6 with code first. During deployment I need to make an update across and existing linked server. When I try this I get:
"MSDTC on server 'myLocal' is unavailable."
This problem happens when running agianst my local instance. MSDTC is not enabled on that instance but I have no trouble running this update manually in SQL Server. I don't want every developer to have to enable MSDTC for this one command.
I have tried adding this as a migration using a DbMigration.Sql and I get the error. I have also tried it in the seed method of DbMigrationsConfiguration using context.Database.ExecuteSqlCommand and I get the error.
ADO.NET Transaction scopes that go across servers - including linked servers - will automatically start the Distributed Transaction Coordinator (DTC). I think your best bet is to update the other database with a direct call in the migration, rather than through the linked server.
I am developing test application for displaying claims of authenticated identity in MVC-ASP.net (Visual studio 2013)
I have given authentication from active directory in following way.
1.Add new mvc project in solution .
2.click on Change authentication.
3.select organization account
4.select on premises.
5.given federation url
6.App Id url
After running the application i am getting following error.
WIF10201: No valid key mapping found for securityToken: 'System.IdentityModel.Tokens.X509SecurityToken' and issuer: 'http://websso.avanade.com/adfs/services/trust'
This error is coming only for this federation for other federation i am able to see claims.
After searching on internet i am thinking that it is certificate(thumbprint) issue.
But I am not clear with solutions.
Can anybody explain me why this error throwing and solution for the same.
Thanks in Advance !!!
There could be 2 causes for this error.
Missing thumbprint in web.config: Get the actual thumbprint from ADFS and put in web.config under the thumbprint tag
Mismatch in port number between the site and ADFS configuration: Update ADFS configuration with the url containing the correct port number
The second solution fixed it for me...
I ran into this while trying to update a legacy MVC application to use AAD.
I based the changes on a newly created project with organizational authentication and noticed I did not have a connection string named DefaultConnection, which the DatabaseIssuerNameRegistry assumes you will, nor did I have either of the required tables in the database.
Using Vittorio Bertocci's great post with all the details, I refactored the code to integrate the new database tables, created and applied a migration, and inserted the appropriate key and tenant in the new IssuingAuthorityKey and Tenant tables, respectively. I also had to make sure to change the DatabaseIssueNameRegistry to use the existing DbContext.
For solutions created in VS2013 and later, the solution should contain the logic to roll over keys automatically. No need to put the value in the web.config file.
You might run into this issue when migrating your solution from local to another environment. In that case you will probably try to point your solution to a new application in Azure Active Directory. Check the following:
Make sure all urls in the web.config are pointing to the correct url not the one automatically generated when you set it up locally
Remove all enteries from IssuingAuthorityKeys table. The keys will autopopulate when you re-build the solution and run it. On the server you might need to replace the dlls manually for it to refresh
Last and most important, delete all rows from the Tenants table. On the first run on the new environment, an Admin from the owning Active Directory has to sign up and authorize the application.
If the values in both tables are still not populated automatically after these steps, check this article for steps on how to manually get the values.
Thumbprints and server names are case sensitive in web.config. make sure they are typed correctly and restart IIS.
It fixed my issue.
I've created an ADO.NET, MVC4, EF5 project which has a relationship between an entity and the built in Membership provider's User.
I have cloned (using git) my repository to an external server and have set up a database with the same name and run the .edmx.sql file created by ADO.NET.
When I run my site on the external server I get the following exception: "Invalid column name 'User_UserId'."
Looking in the database, I can see that Users, Roles, etc. tables have not been created.
What is the best way to do this kind of deployment and rectify my woes?
Update
So I added the tables in question (Users, Roles, UserRole, Applications) to the database by scripting it from the database on my local machine and still the same error occurs.
This seems to be a problem with the mappings in System.Web.Security.Membership.
Any help please?
Okay! Managed to do it. So for anyone else with the same problem - try this:
Create a new DB on the external server
Run the .edmx.sql file on that DB
Change the connection string to your server's name
Run the site locally - this will create the Users, Roles, etc. tables
I've been trying to create an ASP.net - MVC app that uses entity framework to connect to an Azure database.
I used a database first method to try and create the Model, I was able to connect to my azure database and successfully create the model.
Everything was working perfectly and I was able to retrieve my values from my azure database then I tried to publish the website to an Azure website. The website works fine and I have the website registered as able to use the azure database. When I click on the button that hits the controller to access the database I then get "Sorry, an error occurred while processing your request."
When I looked into this a bit more I seen that when I created my Entity Data model using the wizard it created a connection string to a local db for my entity connection settings. I'm guessing this is saving some entity framework settings but my problem is obviously when I publish the website to Azure it can't access this local db.
Any suggestions on how to either get this DB onto Azure or avoid using this extra database?
Thanks
This is the best tool to migrate your local database to Azure. Before publishing your site change the web.config to point to the Azure database. It will solve your problem.
Like you already explained, it seems that you web.config still points to your local database. Try to look at your web.config and see if you have connection strings pointing to .\SQLExpress, localhost\SQLExpress, ".", ...
Then, like Geenthanga's explains, you need to modify this value before deploying (it should point to your SQL Azure database instead). But you shouldn't do this manually! Instead, consider using web.config transformations, as explained here: Web Deployment: Web.Config Transformation.
This way you can have 2 web.config transformation files:
Web.Debug.config: This file would contain the transformations to add the connection string pointing to your local database.
Web.Release.config: This file would contain the transformations to add the connection string pointing to SQL Azure.
I've created a locally attached SQL Server 2008 Express for an ASP.NET MVC application (in App_Data), but I need to access the built-in users table for relationships to custom models that I'm creating. Since the database is local, it doesn't show up when I run aspnet_regsql.exe. Is there a way around this, or should I be setting up the database as a true SQL Server database and providing scripts to generate the tables?
I'm trying to get an environment configured so anyone who checks out the code will have the database automatically, instead of having to spend time configuring it before they can write any code (basically a situation like Rails has where you can have somebody new check out the code, and maybe with some minor configuration type rake db:create and rake db:migrate and have the entire working environment set up.
I'd recommend using a SQL Server database and you can then use aspnet_regsql.exe to generate the schema for you.
If the membership provider is working make sure you have selected 'Show all files' in solution explorer and check the App_Data folder. The DB will probably be called something like ASPNETDB.MDF. ASP.NET / VS has a habbit of setting this database up for you and trying to hide it.