2

Here is my knowing about ASP.NET SPA:

  1. have to use Upshot to talk to the server;
  2. have to use DbDataController to provide Web APIs;
  3. have to use Entity Framework Code first...

so, many concerns come out:

  1. have to provide metadata for the upshot to work, this will obviously expose the structure of your database;
  2. can i use Entity Framework Database First instead of Code First? You may ask why. Because Code First don't provide you the ability to customize your database(index customization, stored procedure...etc.);
  3. A problem i met: when i add a "TestUpshot.edmx" file(generated from database 'northwind') to the MySpaApp.Models folder(trying to test whether i can use the edmx classes in the MyDbDataController class, and generate proper metadata in the client side), and run the application, there is an exception:"System.ArgumentException: Could not find the conceptual model type for MySpaApp.Models.Categories."...

Need help here, thanks in advance.

Dean

tpeczek
  • 23,867
  • 3
  • 74
  • 77
Dean
  • 1,281
  • 3
  • 15
  • 23
  • Dean, you may want to provide a little bit more information about your specific requirements and what you are trying to accomplish. This may help folks offer a little better guidance as to which tools might be most appropriate for you. – Anthony Gatlin May 21 '12 at 04:09
  • Dean, by the way, a few of your assumptions may not quite be accurate. You can still tweak SQL when using the Code First approach. One question which related to your index assumption was answered http://stackoverflow.com/questions/4995642/add-index-with-entity-framework-code-first-ctp5. – Anthony Gatlin May 21 '12 at 04:12
  • @AnthonyGatlin: Yeah, when I found out that Code First could not customize Index/StoredProcedure, I almost tried to use the "ExecuteSqlCommand" way to build up the whole database, but more problems came out: 1.It's hard to maintain the database part; 2.No ORM module; 3.The DbDataController can not work any more. This is my situation: Microsoft provides me a solution of building an SPA using "EF Code-First" + "ASP.NET MVC4" + "Web API using DbDataController and Upshot" + "Knockout" etc., it's not a mature solution yet, but for now, I don't have a better alternative. Thanks again. – Dean May 21 '12 at 14:41
  • Dean, Stack Overflow says the questions I wanted to ask are "subjective" so I posted them in the Knockout Google forum. Maybe these will be helpful. https://groups.google.com/forum/?fromgroups#!topic/knockoutjs/xrCsaQwmlNs – Anthony Gatlin May 22 '12 at 07:49

2 Answers2

2

I may be missing something, but there is no requirement to use any of the technologies you've listed.

An SPA is just a pattern. You can use whatever you need to achieve that. There may be benefits with choosing certain technologies, ie templates, tutorials, etc.

Doesn't really answer your question, but should lead you to experiment with what you've got.

Simon Halsey
  • 5,459
  • 1
  • 21
  • 32
  • 1
    Well, I'm trying to build up a SPA project using ASP.NET MVC4, There are two sample SPA projects: "Delivery Tracker" by Steven Sanderson and "BigShelf". So far, the best/easiest way to build a SPA is to use these technologies: knockout.js, upshot.js, DbDataController, EF Code First...etc., just like those two sample SPA projects do... – Dean May 14 '12 at 15:24
  • Simon is completely right. There is absolutely no requirement to use any of the technologies you mentioned. You don't even have to use knockout. If you wanted, you could even write a Single Page Application using just plain old JavaScript (but I don't recommend it) with any server-side technology including ASP.NET, PHP, Ruby on Rails, etc. Knockout, Upshot, and EF (Code First Approach) are just what Microsoft seems to be recommending. However, even Microsoft has not thrown their full weight behind Knockout or Upshot--otherwise there would be a lot more documentation available. – Anthony Gatlin May 21 '12 at 04:07
  • @AnthonyGatlin: thanks for the comment. I understand that SPA is just a pattern thing, and it's a good one. I think the sad thing here is that once you have decided to use ASP.NET(ASP.NET MVC in my situation) as the server-side technology, you don't have much choices about the assistive technologies. This is my "techs package": 1.MS SQL Server 2008; 2.EF Code-First as the ORM module; 3.ASP.NET MVC4; 4.Web API to provide data access between server and client(using DbDataController and upshot, which is so convenient); 5.knockout.js to provide MVVM UI bindings. Any other suggestions? – Dean May 21 '12 at 14:08
  • I use CoolStorage to talk to the db. I'm not familiar with upshot, but Knockout is ace. We have so much choice these days, go with whatever you feel comfortable with. I believe you'll get a better understanding if you have to figure out how to use your chosen technologies with a framework. – Simon Halsey May 21 '12 at 17:20
  • Wow Dean! I agree with you completely. I am using exactly the same package. I am working on a detailed post right now where I ask a whole bunch of architectural questions on this topic. I will try to post the reference here as it is related. – Anthony Gatlin May 21 '12 at 20:40
  • 1
    @SimonHalsey: [ASP.NET SPA](http://channel9.msdn.com/Events/TechDays/Techdays-2012-the-Netherlands/2159), take a look at this, it may bring you some thought about upshot. – Dean May 22 '12 at 06:38
  • @AnthonyGatlin: Looking forward to see that~ – Dean May 22 '12 at 06:41
  • Saying that you don't need to use ASP.Net SPA to use the SPA pattern is like saying you don't need to use ASP.Net MVC to use the MVC pattern. True, yet missing the point. – Boris Yankov Jun 07 '12 at 10:28
0

SPA is actually a way to conceptualize your client application. SPA comes the closest to the fat client - data server concept from the current web approaches. Definitely this will be the ruling concept within a couple of years.

Your concerns can be addressed using JayData at http://jaydata.codeplex.com that provides advanced, high level data access for JavaScript against any kind of EntityFramework back-ends (db, model or code first). Check out this video that presents the whole cycle from importing your EDMX from SQL (this could eighter be model first definition as well) to inserting a new product item in the Products table from JavaScript.

Peter Aron Zentai
  • 11,482
  • 5
  • 41
  • 71