Entity framework application crashing on other system, - entity-framework

i have made an application having entity framewrok. It is wpf application, now it runs fine on my computer, but when i run this application on another system it crashes, i debugged it on other system, exception came when i try to access data of entities, what could be problem,

The underlying provider failed on Open either means that your connection string is incorrect or the application doesn't have access permission to the database (either SQL account specified in connection string or current user running the application).

Related

.NET Core Entity Framework on AWS

I've got a web application written in .NET Core using Entity Framework to connect to a SQL Server database. Everything works fine locally. The staging/production environment for the app is AWS Elastic Beanstalk, and I seem to be stuck on how to get the app to connect to the database there.
I've created an RDS (SQL Server) database underneath the Elastic Beanstalk app.
Connection string:
user id=[USER];password=[PASSWORD];Data Source=[SERVER].rds.amazonaws.com:1433;Initial Catalog=Development
Creating the DbContext:
services.AddDbContext<MyDbContext>(o =>
o.UseSqlServer(Configuration["Db:ConnectionString"]));
App fails to start, based on the following line in Startup.cs:
dbContext.Database.EnsureCreated();
You have to troubleshoot step by step as below procedure:
Db Connection string is working or not? Better to use with other app and simple doing the Db Connection testing. It could be possible that firewall block your port 1433.
As per your codes, .NET Core Framework will crate a database by code first approach. So that, you have to make sure, your IIS Application Pool user account has write access to SQL Database. Most probability it could be your problem.

.Net Core 1.0, EntityFramework (SQLite), on IIS, which Windows user to give write permissions to

I'm stuck with a .Net Core 1.0 project I'm not allowed to update to the newest .Net Core version yet, and currently trying to deploy it to a development IIS (8.5, on Server 2012 R2).
Slowly working through the list of errors now… and I've come across a strange case with an sqlite database the service uses internally.
The project has a postpublish step that grants write permissions (to IIS AppPool\DefaultAppPool on the machine running the IIS) for a few files the service needs to be able to write.
All but the sqlite file are writeable from the service afterwards, and are correctly being updated.
For the sqlite database however it throws a SqliteException SQLite Error 14: 'unable to open database file', unless I give Full Access not only to the DefaultAppPool user mentioned above, but Everybody—so to me it looks like the EF code is executed in another user context than the rest of the service.
Does anyone know which user, or how I could best find out (or what else might be the problem)?

Sync failed:-857 The remote database identified by remote ID '%1' is already synchronizing or the database connection is unusable:

I am working with iOS native application in iOS using objective C and SUP as middleware .I am using the same provisioning profile for two fifferent application to run in iPAD.
My application was working well before . But now when I try to run it is showing an error like,
The remote database identified by remote ID '%1' is already synchronizing or the database connection is unusable: unable to access the lock for that remote ID
Error code -10343
What can I do to solve this?
when I searched in google I got some informations like
'The MobiLink server could not access the lock for the remote ID in the consolidated database or the MobiLink system database. The remote ID may have been locked by another synchronization, or the database connection may be unusable. Please check the database connection and try the synchronization later.
Please help me ...Thanks for any help in advance...
'
I think this is because the database is locked by some applications.

Is This MSDTC configuration Issue?

It seems I am running into the Microsoft Distributed Transaction Coordinator (MSDTC) related issue.
SCENARIO
I am using TransactionScope and with in the single scope it hits two different databases on different servers (for instance, DB_A running Windows Server 2003 and DB_B running Windows Server 2008). One database is accessed using Entity Framework 4.0 and another using normal ADO.NET APIs.
When I run the application from my development machine (running WinXP) it commits and rollbacks both the connections accurately. But when I run the application, deployed on another server (for instance WAS_A running Windows Server 2003) it commits correctly but in case of exception is doesn't roll back the database activities on both the servers.
I thought it would be the MSDTC configuration issue on the WAS_A. So I went to the MSDTC -> Security Configuration and checked all the available options (as I did previously on other machines). But still I am facing the same issue.
Looking for your expert advices. :)
I believe that you need to look into Enabling Transaction Flow. Specifically, take a look at how one may error and the other complete as described in TransactionScope and WCF Services:
an error in a second WCF service call was NOT rolling back the changes made in a previous WCF service call...
In order to create an ambient transaction in your client and ensure that it is used by your WCF services...
The article then details the following steps:
Configure Your Binding with transactionFlow
Decorate Your Interface with [TransactionFlow(TransactionFlowOption)]
Decorate Your Method with [OperationBehavior(TransactionScopeRequired)]
Optionally update your Connection Strings with Transaction Binding*
*Note: This is optional in my opinion.

How to prevent SQL Server Express database file auto-creation error?

When I try to run an MVC 2 app on my local IIS 7, I keep getting this error:
Failed to generate a user instance of SQL Server due to failure in
retrieving the user's local application data path. Please make sure
the user has a local user profile on the computer. The connection will
be closed.
However, I don't have anything connected to SQL Server Express, and all my connection strings work fine when I'm running on my localhost.
What is the cause of such an error? How can I prevent it?
ASP.NET applications, including MVC 2 ones, by default create a SQL Server database to store users and roles. The database is called ASPNETDB and is stored in App_Data folder - if it is not there yet, ASP.NET will try to create it when the application starts.
To create/open this database, User instance of SQL Server Express is used. To start a User Instance the user profile must be loaded for the current user (in this case whatever account the ASP.NET application pool runs as). But the default configuration for IIS application pools is not to load the user profile to limit start time time and save memory.
To enable loading user profile for an application pool go to its configuration in IIS Manager and look for Load User Profile switch in Advanced Options. Set it to true and it should work.
If you would rather avoid using User Instances and loading the user profile, you can use a different database for your application's users and roles. Just go to IIS Manager again, find your Web Site, and look for Connection Strings section in ASP.NET configuration. I bet you will see a connection string called LocalSqlServer there. Just update it to point to the database you want to use. You can see this thread to learn how to create a new ASPNETDB database. If you create it on the main SQL Server instance you will not need the profile to connect to - just create a login in SQL Server and make sure your connection string is using it.