Have EF automatically resend queries after various errors [closed] - entity-framework

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
When I execute a command against a redundant SQL configuration (such as SQL Azure), I sometimes get timeouts and other misc. errors that are due to a server being shutdown or failing. On Azure this isn't a problem, since redundancy is built-in. The correct action is to re-attempt the query with a new connection, and most likely the load balancers (or whatever) will kick you over to a server that's functioning properly.
My question is whether there is a way to have Entity Framework (v4 or v5) do this automatically? Wrapping every query with a try/catch block (that reattempts the query if certain errors are received) is impractically, and I feel confident that there's a solution to this problem that I'm overlooking.
For related information about SQL Azure's random closing of connections, see: http://msdn.microsoft.com/en-us/library/ee336245.aspx#cc. However, as of late, I have not gotten this error from Azure at all... I just got the occasional, sporadic SQL timeout.

have a look at the Transient Fault Handling Framework from SQL CAT :
http://windowsazurecat.com/2010/12/sql-azure-and-entity-framework-connection-fault-handling/
=== Added by #pbarranis ===
According to that same site, but a different page:
The Transient Fault Handling Framework has been superseded by a newer
deliverable from the Patterns & Practices team. It is now called the
Transient Fault Handling Application Block and comes in all 3 flavors:
•Developer guidance:
http://msdn.microsoft.com/en-us/library/hh680934(v=PandP.50).aspx
•NuGet package:
http://nuget.org/List/Packages/EnterpriseLibrary.WindowsAzure.TransientFaultHandling
•Source code:
http://nuget.org/List/Packages/EnterpriseLibrary.Source.WindowsAzure
The new Transient Fault Handling Application Block is now our
officially recommended approach to handling transient faults in the
applications running on the Windows Azure platform.

If you use Entity Framework 6 (currently in alpha) then there is some new in-built support for transient retries with Azure SQL Database (with a little bit of configuration): http://entityframework.codeplex.com/wikipage?title=Connection%20Resiliency%20Spec
I've created a library which allows you to configure Entity Framework to retry using the Fault Handling block without needing to change every database call - generally you will only need to change your config file and possibly one or two lines of code.
This allows you to use it for Entity Framework or Linq To Sql.
https://github.com/robdmoore/ReliableDbProvider

Related

Play migrations alternatives [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am about to start a new project that will use the Play! 2 framework for Scala, probably using Squeryl as ORM (but maybe Slick would be fine too, if it ready in time).
Now, Play! has a feature to upgrade your database using migrations. Unforunately, these migrations are written in SQL. This is not only an inconvenience (I would like to be able to write migrations in Scala) but has two problems
first, I need to write migrations on my own. I am used to South, that is able to infer schema migrations by looking at the current and previous definitions of my models;
second, it would be very cumbersome to handle data migrations. One may have the need to alter data programmatically, and this may not even be doable in plain SQL.
So, I am looking for an alternative. I was not able to find any migration tool for any Scala ORM that would generate schema migrations automatically, is there any?
The best tool I could find is Scala migrations. Is there a way to make Play! automatically use it in place of its own migration tool?
Another alternative is Flyway, but it will not solve your integration issue.
For that, either you can implement a Plugin as it is done with standard Play! evolutions, either you could use the Global object to start the migration on the application start.
Evolutions in Play2 is implemented as a plugin. You could examine its implementation and roll your own along the same lines. As far as I can see, there isn't a simple way to just swap out the implementation for another.
One other tool that might be worth looking at is Liquibase. It is implemented in Java so should be easy to use from Scala.
I recommend liquibase. Liquibase is an open source, database-independent library for tracking, managing and applying database changes. It is built on a simple premise: All database changes are stored in a human readable yet trackable form and checked into source control. Liquibase can be used for both Java and Scala. The great thing about Liquibase is that you can use either XML, SQL, or combination of both for your db migration needs. It is easy to set up and use and has very extensive documents.

Crash analytics and reporting for iOS [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
We are in the process of evaluating a 3rd party solution or custom solution for our iOS app for crash reporting. We are looking at Crashlytics, BugSense, Testflight. They all seem to serve the purpose i.e. live crash reporting.
Also, we have been looking at custom solution implementation along the lines of Xcode 4.2 debug doesn't symbolicate stack call
2 questions:
Does a 3rd party solution (Crashlytics, BugSense etc) provide an advantage over a custom solution when the only purpose that we want to use it for is crash reporting?
How much of a functionality can we add to the custom exception handler e.g. if I want to post the stacktrace to a server with HTTP post, can I do it in the exception handler or do I need to wait until my application launches the next time to send the logs? How soon should an exception handler exit?
Thanks,
Hetal
You shouldn't do your own crash reporting solution, but use an existing solution because writing a reliable and safe crash reporter is hard. Landon Fuller, developer of PLCrashReporter, explains why in this article: Reliable Crash Reporting
In general running any non async-safe code once the crash occurred, should be avoided at any cost! This means that any Objective-C code has to be avoided at all. This also means that you crash reports should only send to your server at the next launch. You should also not rely on a 3rd party framework using PLCrashReporter per default, as whatever the framework does in addition should be implemented done async-safe too.
Writing your own exception handler will hardly ever be as detailed, good and reliable as anything based on PLCrashReporter.
In addition to your mentioned 3rd party solutions, there is also the open source solution QuincyKit (based on PLCrashReporter with a companion PHP based basic server solution) and HockeyApp, which can also be used with the QuincyKit client. (Note: I am one of the developers of these two solutions)

Why is there no ActiveRecord REST adapter [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
We've been working on various projects using ActiveResource for a couple years now. It seems that ActiveResource is great to use if you are using Rails on both the client and server sides.
Problems with ActiveResource
We're using Scala on the server side and constantly running up against "Oh, ActiveResource doesn't want the API to <do this standard thing>" or "ActiveResource does <this weird thing>" so we have to change the server to support the demands of the client. This has all been discussed before, I know.
Another problem is that many gems and libraries require ActiveRecord. I can't count the number of gems we've run into that "require" your model to use ActiveRecord even though they don't actually use the actual AR functionality. It seems this is mostly because that's the easy path for gem development. "I'm using ActiveRecord, and can't imagine anyone not using it, so I'll just require that rather than figure out the more general way" (note, I've done this myself, so I'm not simply complaining)
So, if we use ActiveResource, we have to break the server to make it work, and we can't use a large portion of what makes Rails great.
REST Adapter?
All of this brought us to ask the question "Why does ActiveResource exist at all?" I mean, why would you have this secondary data storage path? Why isn't ActiveResource just a REST adapter? With a REST adapter, you can have all the good things in all the gems, and don't have to fight with ActiveResource's finicky nature. You just build your model the same way you build any model.
So I started exploring building one. It actually doesn't seem difficult at all. A few hours work and you could have the basic functionality built up. There are examples elsewhere using REST and SOAP, so it's doable.
So the question comes back. If it's so easy, why the hell hasn't this been done before?
Not simply a datastore?
I've come up with what I wonder is the answer. While building up a scaffold for this, I quickly ran into an issue. REST is very good at doing two things: 1) Act on this object, and 2) Act on all objects. In fact, that's pretty much the limit of the REST standard.
And so I started to wonder if scope is the reason there's no REST adapter. The ActiveRecord subsystem seems to need more than just "get one" and "get all." It's based on querying the datastore as much as anything.
The Actual Question
So, the actual question: Is there no ActiveRecord REST adapter simply because REST defines no standardized way to say "give me all of the cars where the car is in the same parking lot as these drivers and the drivers have a key."
That's right.
Unlike databases which have SQL as a standard way to express conditions, there is no standard in REST to support all the ActiveRecord functions, such as joins, group, and having.
How many hours work do you think it would take to do correlated queries or sub-queries?
I'm not being casually dismissive here. This concept touches on some personal projects I've considered, with some of the same issues I've been thinking through.
ActiveRecord supports all of SQL, which is way more powerful than most people use or need. Basically every part of an SQL statement has an ActiveRecord method which takes a string to fill in that section of the SQL.
You'd want to limit the client to the part of ActiveRecord people actually use. You'd still need IS NULL, and IS NOT NULL. You'd need comparisons such as less than and greater than. You'd want to support OR statements, for "field1 IS NULL OR field1 = ''".
To do all the comparison stuff, like where(["updated_at > ?", cutoff]) you would need a RESTful server more robust than existing web services. The server would have to use your gem, or be built with guidelines for implementing all the functionality.
So, in the end why? You're implementing a limited database API, going over the network with string URLs instead of binary packets, to a database engine that you are implementing.
On the other hand, if there was a standard for this, there might be good benefit to such an implementation.
If there was an implementation which one could install on a RESTful web server, which, while maybe not as powerful as SQL, could do indexed queries, post index processing of simple non-indexable expressions to qualify records return, and sort, (even if passing this to an SQL database do all the work), one could enable this on a server, and products, like Crystal Reports could be developed to use the standard for a report client.
Going through the web server API layer, could provide a way to enforce restrictions on what database operations could be performed to provide more security than fully opening up database access. Also, logic could be added to the web service to audit and do processing on events resulting from the CRUD operations (essentially triggers). Yes, database products supply security policies, triggers, and stored procedures to do these things, but with the product we are discussing, one could do it more easily in ruby, than using the database functions.
One could also have pseudo data, which is calculated from ruby code but acts like database records, along side the general DB RESTful access. Sure, databases can do this which store procedures, and some support writing stored procedures in Java, but this would be better because it would be easier to implement and could be written in ruby.

Entity Framework 4 Code-First pros and cons [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I would like to know the pros and cons of using EF4 Code-First approach. Can we duplicate all features that EF4 generated classes offer like Lazy Loading, loading related entities, etc?
Thanks
Pros
Lightweight entity classes or POCO based.
More control over entity classes since you code them yourself rather than depending on EF to generate them. This means you don't have to define partial classes to do data annotations.
Option to never have to specify mapping anywhere. Convention takes over configuration.
DbContext follows the repository pattern.
Lazy loading, related entity loading all taken care of for you. For example a Post model can declare Author model in the POCO and EF Code first will map this relation automatically. Again use of convention makes us so productive.
Works great for greenfield applications.
ASP.NET MVC view generation works great.
ModelBinder works as per normal.
Cons
No API support for customizing the database mapping convention like in Fluent nHibernate.
Bit difficult to map to existing databases.(This might change in the release version).
For sample code and mapping to existing databases using EF 4.0 Code First see this blog post.
http://theminimalistdeveloper.com/2010/07/28/how-to-map-pocos-to-existing-databases-in-entity-framework-4-0-code-first-and-asp-net-mvc-2/
Cons:
Since you have no EDMX, you can't pregenerate views
Not yet licensed for go-live. Hopefully, this will change soon.
Pros
Since there is no fixed schema, you can dynamically build one at runtime.
Most other things are exactly the same (lazy loading, explicit loading, etc.). A few more are matters of personal preference (the API).
Since you asked specifically about Lazy Loading, here's a writeup showing Working with Lazy Loading with Entity Framework Code First, where it's enabled by default. To specifically answer that part of your question, yes with Code First you still get the benefits of Lazy Loading, and in fact as the post shows, you have very fine-grained control over this feature.

good postgresql client for windows? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
coming back to postgresql after several years of oracle ...
what are the state-of-the art postgresql administrative/ddl generating/data inserting frontends on windows? it would be nice if it had integration for postgis as well. it should be standalone or alternatively a plugin for intellij idea
thinking back, all the windows programs specific for postgresql i have used were crap, especially PGAdmin. had it become better?
do you mean something like pgAdmin for administration?
I like Postgresql Maestro. I also use their version for MySql. I'm pretty statisfied with their product. Or you can use the free tool PgAdmin.
I heartily recommended dbVis. The client runs on Mac, Windows and Linux and supports a variety of database servers, including PostgreSQL.
Actually there is a freeware version of EMS's SQL Manager which is quite powerful
I recommend Navicat strongly. What I found particularly excellent are it's import functions - you can import almost any data format (Access, Excel, DBF, Lotus ...), define a mapping between the source and destination which can be saved and is repeatable (I even keep my mappings under version control).
I have tried SQLMaestro and found it buggy (particularly for data import); PGAdmin is limited.
For anyone looking for a web-enabled client for Postgres, I'll just put the link out here to TeamPostgreSQL, a very polished AJAX web client for pg:
http://www.teampostgresql.com
EMS's SQL Manager is much easier to use and has many more features than either phpPgAdmin or PG Admin III. However, it's windows only and you have to pay for it.
SQLExplorer is a great Eclipse plugin or standalone interface that works with many different database systems, either with dedicated drivers or with ODBC.
phpPgAdmin is PostgreSQL web frontend which is quite good.