Thursday, November 28, 2013

ASP.NET MVC: Simple CRUD (Entity Framework) example

MVC 4 - Simple CRUD (Entity Framework) example with composite primary key PART 1

Watch this example on YouTube:


In my database I have table called TestCompositePrimary - it has composite primary key.



Table is related to StyleMaster and ColorMaster








This step by step tutorial will show you how to add/edit/delete records in this table using MVC 4 /Entity Framework EF.
First - create new project


Ensure it is Internet application


Right click Models folder and add new item

Follow the instructions (connect to database and select tables - all details in the YouTube example)
Once completed you will be able to see all 3 tables (that we need for this example)

Rebuild the solution (you have to rebuild solution whenever you modify EF)

Now right click Controller folder and add new controller.

 Name new controller TestController


Ensure that template, model class and data context class are correct and pointing to our test table.



 Test controller is created with all CRUD functionality (add,delete, etc).  Also in View folder another subfolder has been created with all screens that are needed to add/edit/delete items in our table.
Lets run the program and point to http://localhost:50566/Test (your port number may be different than my 50566).

 you can view all records in out table.  Click create new and add new record - program will create new record.  Now try to edit or delete record - you will get error "The number of primary key values passed must match number of primary key values defined on the entity."


 Our table has composite primary key, we have to let our program know about it.
First open Index.cshtml file that is located in test folder in View








 Go to part 2
http://howtodomssqlcsharpexcelaccess.blogspot.ca/2013/03/mvc-4-simple-crud-entity-framework_21.html

SITECORE: Performance Tuning Guide

Note: Full-sized "CMS Performance Tuning Guide" document containing detailed instructions on how to implement most of the listed in this article items can be found here.
This article contains a list of items that you should investigate if your Sitecore installation is experiencing poor performance. You can also investigate these before putting your Sitecore website into production.
This is not a complete or detailed guide, but rather an outline of the most generic and efficient optimizations that you can perform based on the experience of Sitecore Support team members.
  1. Ensure that the IIS environment is up-to date
    • Windows Server 2008 R2 x64 is highly recommended. It contains a lot of valuable bug fixes and new features compared to Windows Server 2003.
    • 64 bit application pool mode is highly recommended. This allows you to allocate more memory to the application.
    • 4 or more processor cores are highly recommended.
    • For high volume Sitecore solutions (for example, more than 20k item versions), we recommend that a minimum of 4GB of RAM should be available for the w3wp.exe process. This enables Sitecore cache sizes to increase, improves performance, and decreases the load on SQL Server.
  2. Optimize Sitecore caches.
    • Increase and tune the size of the data, items, and prefetch caches. Bigger caches = better performance.
    • Always use HTML caching and make almost all the renderings on the site cacheable. Then tune the size of HTML caches.
    • Tune the sizes of other caches if they are reaching their threshold.
    • Tune or disable initial prefetching. Do not disable the actual prefetch caches — you should only increase their size. This can affect startup times.

      For more information about Sitecore caches, see the Cache Configuration Reference article.
  3. Optimize Sitecore databases
    • Make sure that all the connected SQL databases are on the same network. For example, going through the public firewall is a no-go for the database performance.
      For information about testing connection speeds, see the Testing Database Performance article.
    • Use the database cleanup tool to remove artifact data from the databases. Click Desktop, Sitecore, Control Panel, Database, Clean Up Databases to open the database cleanup tool.
    • Cleanup the following tables from the artifact data. It is safe to completely truncate them before publishing your website. All of these tables should be automatically cleaned up on a periodic basis:
      • History – cleaned up by Sitecore.Tasks.CleanupHistory agent
      • PublishQueue – cleaned up by Sitecore.Tasks.CleanupPublishQueue agent
      • EventQueue – cleaned up by Sitecore.Tasks.CleanupEventQueue
    • Rebuild all the database indexes and implement maintenance plans:
      http://www.theclientview.net/?p=40
    • Set up the database properties:
      http://www.theclientview.net/?p=162
    • Run DBCC CHECKDB to check for database consistency errors
    • Tune the Analytics database.
      For more information about improving the performance of the Analytics database, see the OMS Performance Tuning Guide.
  4. Sitecore Client specific optimizations
    • Make sure that content authors never use Full publish — they should only use Smart or Incremental publishing.
    • Enable content expiration in IIS. In that case the web browsers won't request all the static files from the server second time until their expiration date is passed. Sitecore Client uses a lot of static files.
    • Enable static HTTP content compression in IIS.
    • Enable dynamic HTTP content compression in IIS. This speeds up both the Sitecore client and the public web site and is especially beneficial in environments with a low bandwidth.
    • Set the ContentEditor.RenderCollapsedSections setting to False. This is a hidden setting that is set to True by default. Changing this setting can help a lot.
    • Set the ContentEditor.CheckHasChildrenOnTreeNodes and the ContentEditor.CheckSecurityOnTreeNodes settings to False. Changing these settings doesn’t normally help much, but you should still test whether or not this helps.
    • Check long running validators and disable any default validators that you don’t need. They are often the cause of bad performance.
    • Do not show Standard Fields in Content Editor.
    • Limit the number of items that share the same parent to 100 items per parent.
  5. Cleanup obsolete versions and ensure they do not grow unrestricted – we do recommend to have no more than 5-10 versions per item in Master database. Use the Version Manager shared source tool for this. http://marketplace.sitecore.net/en/Modules/Version_Manager.aspx
  6. Check this article: http://sdn.sitecore.net/Scrapbook/Delay%20while%20validating%20digital%20signatures.aspx
  7. Monitor Sitecore log files for any application restarts. If a new log file is generated, this often means that a restart has occured. Identify the reason for the restart and address it.
    • If the log file ends with a "Sitecore shutting down" message – this is a "soft crash" and for some reason the hosting environment has forced the process to recycle (for example, due to some scheduled recycling or some critical file changes).
    • If the log file does not end with a "Sitecore shutting down" message – this a “hard crash” due to for example a stack overflow error or some worker thread deadlocks. A good solution could be to collect a process crash dump and analyze it with WinDbg.
  8. Disable search indexes if you don't use them. Set Indexing.UpdateInterval to 00:00:00.
  9. Watch out for any scheduled operations that may be running in the background - especially any custom made operations that for example perform a complete rebuilding of the Lucene index.
  10. Perform load testing and profiling of your solution to find slow running pages and code paths. This is the most efficient way to identify any custom code and configuration issues.
    • Load test the solution for example using:
    • Profile your solution while stress testing (for example, by using the ANTS Performance profiler) to find bottlenecks in the code that may need to be optimized.
    • Valuable for understanding the health and performance of your application health and Windows performance counters:
      • % time in GC
      • # Induced GC
      • # Bytes in all Heaps
      • # Total committed bytes
      • # Total reserved bytes
      • Request/Sec
      • Request Execution Time
    • Valuable for understanding Sitecore caching state counters:
      • CacheHits
      • CacheMisses
      • CacheClearings
      • Data.PhysicalReads
      • Data.PhysicalWrites
       
       
       reference:http://sdn.sitecore.net/Articles/Administration/Sitecore%20Performance/Optimizing%20Sitecore%206%20and%20later/Optimizing%20Performance%20in%20Sitecore.aspx

SITECORE: Overview

Question #1: Why Should I Use Sitecore?

Entire conferences are devoted to answering this question; however, for the sake of brevity, just know that Sitecore is one of the most powerful CMS platforms available. It masters the functions of a traditional CMS while integrating a ton of powerful tools that have transformed it into a “one-stop-shop” solution.
With Sitecore, businesses can finally bridge the gap between marketing and IT in an effective manner.
A few benefits of Sitecore:
  • Integrates extremely well with existing Microsoft programs.
  • Right message, right channel, right time
  • Dynamic content personalization
  • Fully customizable
  • Top enterprise grade Security and Support
  • Has great Documentation
  • Multilingual
  • WYSIWYG
  • Works with databases (SQL)
  • Powerful Tools (DMS, Email Campaign Manager)

Question #2: Why Does Sitecore Cost So Much?

Let’s put it this way. Would you rather fly across the country in a private jet, or hitch a ride in a windowless van with a stranger you met on the “rideshare” section of Craigslist? Yes, both options will get you from point A to point B (hopefully), but the experience and quality of your trip will be entirely different.
Sitecore is the private jet of CMS platforms. It is an enterprise grade product that features some of the most innovative and powerful technology on the market. Many of the cheaper alternatives are not designed to handle the intricate facets of enterprise grade websites. The higher price tag ensures that the specific needs of enterprises are met.
Many of Sitecore’s enterprise grade competitors, similar to the windowless van, can still get you to where you need to go, but the ease of use, quality, and power of Sitecore will be absent. You get what you pay for.

Question #3: What do I get from Sitecore out of the box?

Out of the box, Sitecore comes with a Content Management System (CMS), Digital Marketing System, (DMS), and a Customer Engagement Platform (CEP). All of these tools are extremely innovative and have the potential to be very powerful. They are not, however, meant to be the “end all” solution directly out of the box. Initially, they are more of a springboard to build upon. Martin English, an Arke Sitecore developer, explains that “Sitecore gives you a solid foundation with countless tools which allows for robust customization. This ensures that Sitecore is the perfect fit for your business.” Sitecore is so powerful because it focuses on user customization and individual business needs, instead of “prebuilt” one size fits all solutions.

Question #4: Is my company ready for Sitecore?

We usually don’t recommend Sitecore for inexperienced or non-enterprise companies. While Sitecore’s user experience is relatively straightforward (the development side is a whole different story), many of the more advanced features, the ones that make Sitecore so expensive, will most likely go to waste if the user has had no prior CMS experience. It will basically be a very expensive learning tool. For smaller businesses–it’s overkill. The only reason a business should be investing in an enterprise grade solution is if they are indeed an enterprise.

Question #5: What is the implementation process like?

The implementation process is different for every business that tries to adopt Sitecore. Variables such as needs, experience, and practices can affect the time and difficulty that defines the entire process. There is one aspect, however, of implementation that reaches across all differentiating variables—data migration. Countless hours are spent finding, moving, testing, and updating content. Very few businesses have a complete web inventory which is why data migration issues tend to reach across business variables.
Finally, it is important to realize that no matter how large or difficult Sitecore adoption may be, you do not have to do it alone. Companies, like Arke, are here to help and guide you through the entire process. Arke, in particular, is great at developing detailed plans and ensuring that things run as smoothly as possible.

Question # 6: We have Sitecore already, but what tools am I not utilizing?

One of the most common features that Sitecore users neglect to utilize is DMS (Digital Marketing System). The engagement analytics, integrated email marketing, engagement automation, and sales automation features of DMS make it the ideal marketer’s “tool box.”  All of these powerful tools are easy to find in the “Marketing Center,” and are designed to improve conversion rates and generate more qualified leads through web, email, mobile and social channels. It allows businesses to target particular customers with predefined types of content. This in turn makes relevant content easier to access, and therefore increases conversion rates.  Despite these amazing benefits, many marketers still refuse to use the DMS. Marketers often fear learning a new system and are scared to part with the tools that they have grown accustom to.  Also, many people fear that they don’t have the technical knowledge or skill to use the DMS effectively. Unfortunately, fear makes it impossible for a company to experience the full potential and benefits of Sitecore. If fear is holding you back, take a look at “Top 6 Reasons Why Sitecore’s DMS Seems Scary, But Really Isn’t.”

reference: