which dll or namespace of ASP.net 4 (MVC5) should not be present in ASP.5 (MVC6) after migration - asp.net-core

Hi I understood from post available at below link
http://docs.asp.net/en/latest/conceptual-overview/aspnet.html
http://weblogs.asp.net/scottgu/introducing-asp-net-5
that ASP.Net 5 no longer required to have system.web.dll, what are the other namespace it should not have.
My MVC 5 project references system.web.extension.dll perticulary JavaScriptSerializer Class, i am not sure if should be using that or if there is any other alternative to it.
there are other namespaces also start with system.web as below should that also be avoided
using System.Web.Http;
using System.Web.Http.ModelBinding;
using System.Web.OData;
using System.Web.OData.Routing;
is it that only system.web.dll should not be used in ASP.net 5 MVC 6 project.

I believe anything beginning system.web.* shouldn't be there and has been replaced with something within Microsoft.AspNet.
I'm not sure how you are planning on doing the migration but the article Migrating From ASP.NET MVC 5 to MVC 6 on docs.asp.net covers the process pretty well.
Essentially it advises starting with a blank MVC 6 / Asp.Net.Core 1 (the new name for Asp.Net 5) project and porting the content over.
That way you can lean on the compiler to tell you things that aren't available. A lot of what can / can't will depend on wether its Framework 4.6 or .NET Core 1.0 (prevously .NET Core 5).
As for JavaScriptSerializer I believe the recomended alternative is Newtonsoft.Json.
Depending what you use it for there is also now JsonOutputFormatter and JsonInputFormatter
I haven't been through the full process yet, but I strongly suspect moving to Framework 4.6 will be the easier destination :-)

Related

How do I use JavaScriptSerializer in ASP.NET 5?

I am porting my project to DNX-Core 5.0 and trying to get work but I cannot find the JavaScriptSerializer and AppSettingReader classes. I know the System.Web is removed and so please anyone help me to find the alternative of using them.
Is there any Nuget available to include them?
The ASP.Net 5 team dropped the JavaScriptSerializer in favor of the widely used Newtonsoft.Json package, but they did provide a JsonOutputFormatter and a JsonInputFormatter for use with MVC to be able to return objects more directly.
For the AppSettingReader you'll want to look at the new ASP.Net 5 Configuration Model. This has been detailed in a few blog posts while it's being built. These posts only detail how to load out individual fields, but the tests in the Options Model show that you can bind directly to an object.

Enum type not being mapped to DB table

I'm using EF 5.0 Code First, in a .NET 4 library. Trying to set a class member to be of an Enum type, but it doesn't get persisted to the database, and no runtime exception occurs when EF is creating the database based on the code.
Of course, when I try to query against that Enum:
var departments = db.Departments
.Where(dep => dep.Name == DepartmentNames.English);
I get an exception saying:
The specified type member 'Name' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
I am using Microsoft's example of an Enum use: http://msdn.microsoft.com/en-us/data/hh859576.aspx
Are Enum members not supported yet? Does EF 5.0 differs somehow when hosted by a .NET 4 environemt than when hosted by a .NET 5 one?
Enums where first introduced in EF 5 components that live in .NET Framework 4.5 (System.Data.Entity.dll). If you are using EF5 but target .NET Framework 4 there is no support for enums since they are not supported by the System.Data.Entity.dll that is part of .NET Framework 4. So, yes EF5 on .NET Framework 4 is scoped down when comparing to EF5 on .NET Framework 4.5. Some other features that are available when you target .NET Framework 4.5 but not available when you target .NET Framework 4 are spatial types, Table Valued Functions, strored procedures returning multiple resultsets and a couple more. An alternative is to move to EF6 (Alpha release shipped a few weeks ago) which does not depend on System.Data.Entity.dll and therefore supports all features that shipped in EF5 on both .NET Framework 4.5 and .NET Framework 4 plus some more (e.g. async on .NET Framework 4.5). EF6 is an open source project from Microsoft and you can find all details here: http://entityframework.codeplex.com/

Is the core CLR of Silverlight 4 the same as 'classic' .Net 4?

I ask this because I have been chasing down a co/contravariance issue in SL4. I asked it twice in SO and got answers along the lines of - "It just works, make sure you are using .net 4". I tried my failing code (and the samples people posted) in SL4 and .Net 4 and the results are different (work in .net fail in sl). So is SL4 actually running on a < 4 version. Or are there just some features left out (accidentally or on purpose). If so what features
What about SL 5?
The core compiler in Silverlight 4 supports Covariance and Contravariance, but the framework interfaces (ie: IEnumerable<T>) unfortunately were not marked as covariant (note in the docs that it isn't IEnumerable<out T> as it is in .NET 4).
Silverlight 5 fixes this, "officially" supporting Covariance and Contravariance.

Silverlight 4 and System.Runtime.Serialization

I have a Silverlight 4 project that contains some business objects. I added a Test project. One of the tests is to serialize the business objects from the Silverlight project using DataContractSerializer. To reference DataContractAttribute, I have to add a reference to System.Runtime.Serialization. However, there are different and apparently incompatible versions in the Silverlight runtime and in the .NET 4 Runtime of the Test project.
What's the best strategy to serialize objects in a Silverlight project such that they can be consumed by a standard .NET 4 runtime?
For this purpose i would use the DataContractJsonSerializer. This serializes your business objects to json. It it supported in Silverlight and .NET Framework since 3.5.
An example how to use the serializer can be found here.
If your objects allow it (regarding constraints mentioned below), try a serializer such as protobuf-bet or one of the other protocol buffer implementations.
http://code.google.com/p/protobuf-net/
They place some constraints on the implementation of your business objects (contracts, rather), for example that null and empty collections are considered equivalent to name one example.
I realized this morning that I had added a reference to a Silverlight project from a non-Silverlight project and VS warned about that not being a good idea, but still allowed the non-Silverlight project to run. Because a different version of System.Runtime.Serialization was referenced in each project, the unit test aborted with an inability to load that DLL.

nhibernate: simple template project

I have been using NHibernate for a few years, but whenever I have a question I find myself in the situation of "it would take me 8h to build a sample app/adapt my business-code before I can ask a question".
Is there a simple Visual Studio project out there (maybe even including something like "AbstractDomainObject") to download which one can reference?
Cheers, Patrick
Sharp Architecture is a good place to start as it "provides a solid architectural foundation for rapidly building maintainable web applications leveraging the ASP.NET MVC framework with NHibernate." The Sharp Architecture zip files can be found at GitHub.
Another possibility would be use to the .NET Reference App which is used in Headspring's Agile Boot Camp training.
Finally, the example source code provided with ASP.NET MVC in Action could also be useful.