Connection Strings in local exe.config removed (using EF) - c#

Imprtant note: this is only happening on clients, not in dev environment
I'm having an odd issue. An application I have written / deployed at my company uses 3 connection strings within it to query data from various sources as needed. Every so often, I get an error report from one of the end users machines stating something like
System.InvalidOperationException
No connection string named 'CM_PS1Context' could be found in the application config file.
So, I went to this machine, opened up the exe.config file, and sure enough, 2 of the connection string entries were just.... gone. I went to my machine, grabbed the entries from my config, dropped them in, everything was working again.
I can't make heads or tails of this, nothing in my code is modifying the app.config (user.config, yes). I am using EntityFramework for all 3 databases. Has anyone seen this, or maybe has an idea of what might be happening?
Note, this is not happening to all clients, it seems very very random at the moment, as I am unable to reproduce the error myself (nor can anyone if they are trying)
For the moment, my fix is going to be something retarded like watching for that error and when it occurs, reinsert the connection string, but... that's a very messy, ugly fix, that I'd prefer NOT to put in production. Any suggestions would be very helpful!

Related

WCF Rest Service - Publishing issue

I just recently posted my first WCF Rest service. It works great so far. Yesterday a request came in to alter something in the database table that houses the entries that come in to us via this service. Since the contract wasn't changing, it was basically a change to the insert within the datalayer, I assumed this change could be implemented easily. So I modified the insert, recompiled the code and republished the site/service.
The next time we received a request, it did not perform my updated insert, but rather the old version from the prior build. I thought perhaps I screwed up something compiling, so I recompiled and posted again. But ended with the same result.
Has anyone seen this happen before? How is this possible? Assuming I must be overlooking something minor.
Turned out to be an issue with the DNS pointing to another server hosting an older, outdated version of the process that was suppose to have been decommissioned.

Finished program. Proceeding to production and migrating from LocalDB

Until now all of my questions creating the program itself [C# Winforms] have been answered by searching the SO database. It's been an immense help really. But now i'm through with my program and I want to know what sort of procedure comes after; what is involved in the migration to an operating sql server.
I built my program with [Visual Studio 2013] to operate temporarily on a LocalDb for testing purposes. I noticed that nothing gets saved whenever I close the application, which actually saves alot of time during several test runs, but now I want it to save permanently on the published software system.
I've researched this topic abit and this is what i've come up with so far:
I would first setup the connectionstring to work with my sql server (MSSQLSERVEREXPRESS 2012/2014)
Publish my program. (For this I have prepared an install shield wizard. is this preferrable over a ClickOnce application?)
Run and prep the Sqlservice (No idea how to do this... I know, I know... but I'm really only fluent in the coding department)
Based on what I read, I would want to attach my database (.mdf service based database) through SQL management studio.
?? I'm not sure what happens after five.
Am I correct in these assumptions?
A) Would the program run just as simply as the LocalDb variant?
B) Would I finally be able to create permanent records?
C) Would the Sqlservice have to be ran each time, alongside the program?
D) What am I not seeing? What procedure am I missing?
All forms of help are appreciated. Do note that I have researched lightly about the topic, and have so far only come up with the idea to attach the Mdf to the server through SSManagementStudio and the rest is magic (so to speak).
Honestly, I know too little about sql server that I might not even be running on LocalDB, as I've read on another thread that I was merely working with Visual studio's SSData Tools (I've never consciously ran an SqlServer during the course of creating my program). But for the record, localDB is written on my connectionstring.
The problem has been [Resolved]!
FYI LocalDB is awesome and really isn't a hassle to deal with. I merely changed the COPY property below build options on the MDF file to Copy if Newer. Then I included everything I need into an InstallShield Wizard installer. Next problem came up was resolved by giving permission to use the MDF and LDF files to all users. I can now save permanent records. Thanks again Steve!

ASP.NET with EF 4 getting incorrect data from SQL Server database

I updated my ASP.NET site from Linq-to-SQL to EF 4. I've had a bunch of hiccups along the way but have ironed most out.
Not sure if it has anything to do with EF but recently my application has started going nuts at random times. I'll delete one or multiple records from my SQL Server database, but when I re-display the page that was listing those records they're still there. I check my database and the records are gone yet when my code queries for this data after it's deleted my data model is still getting that deleted data and displaying it on my site. The only way I've found to get around the issue is closing the web browser or stopping my local host when debugging. Obviously not the fix I want. It happens on server code and local host.
This problem is very rare and difficult to reproduce and it only happens some days but not most days. I'd like to say it's completely random but I know there has to be some variable and I can't figure it out. Any suggestions?

"Invalid attempt to read when no data is present" - why?

I'm getting the error mentioned in my subject line and I don't know why. I have an ADO.net entity and a domain service class and am doing this as I have read in tutorials and what not. Also you should bear in mind that it worked fine up until today, and so far as I know I didn't make any changes.
The database exists and the table is there as it always was. I suppose it's possible someone could have changed the table, but there are still entries (and they seem to be the same as before, but I couldn't guarantee that).
I am still connected to that source and it's not changed IP (I can remote desktop onto the server to see the SQL Server Management Studio).
If you want to ask what changes I made... not really any. I added a drop down box on my page which tells the user when database access is happening and after it finished, but then removing that still left me with this same problem so I rather think it's unrelated. I have searched Google, but none of the solutions seem to be for Silverlight.
Thanks, and I hope someone can shed some light here.

Sql Server Compact Edition concurrency / thread safety (i.e. not thread safe)

Over the last few months I have been developing an application using Entity Framework code first and sql server CE for the first time. I have found the combination of the 2 very useful, and compared to my old way of doing things (particularly ADO.NET) it allows for insanely faster dev times.
However, this morning me and some colleagues came across a problem which we have never seen in any documentation regarding SqlServer CE. It cannot handle more than one insert at once!
I was of the opinion that CE may become my database of choice until I came across this problem. The reason I discovered this was in my application I needed to make multiple requests to a web service at once, and it was introducing a bit of a bottleneck so I proceeded to use a Parallel.Invoke call to make the multiple requests.
This was all working fine untill I turned on my applications message logging service. At this point I began to get the following error when making the web requests:
A duplicate value cannot be inserted into a unique index. [ Table name = Accounts,Constraint name = PK__Accounts__0000000000000016 ]
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlServerCe.SqlCeException: A duplicate value cannot be inserted into a unique index. [ Table name = Accounts,Constraint name = PK__Accounts__0000000000000016 ]
Strange I thought. And my first recation was that it must be something to do with the DbContext, maybe the DbContext I was using was static or something else in my Repository class was static and causing the problem, but after sniffing around I was certaing it was nothing to do with my code.
I then brought it to the attention of my colleagues and after a while it was decided it must be SqlServer CE, and after us all setting up different test projects attempting to recreate the problem using threads it was recreated almost every time, and when using Sql Server Express the problem wasn't ocurring.
I just think it is a bit strange that CE cannot handle something as simple as this. I mean the problem is not only with threading - are you telling me that it cannot be used for a web application where two users may insert into a table at the same time...INSANITY!
Anyway, just wondering if anyone else has come across this late into a project like me and been shocked (and annoyed) that it works this way? Also if anyone could shed light on why it is limited in this way that would be cool.
It looks like a bug in SQL CE. See http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=641518

Categories

Resources