Enum type not being mapped to DB table - .net-4.0

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/

Related

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

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 :-)

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.

WCF Data Services Toolkit with CTP2

Im trying to use the WCF Data Services Toolkit together with Microsoft WCF Data Services March 2011 CTP 2 for .NET Framework 4 and Silverlight 4. But When i use this release i get multiple compile errors regarding missing reference to System.Data.Services. Of course i can't reference that assembly, since i already reference Microsoft. Data.Services and will get alot of "multiple types" error. To me it seems like WCF toolkit has been compiled against the System.Data.Services that ships with .Net 4 and the compiler needs a reference even though im not using any types from that assembly.
So how on earth is Jonathan Carter in the MIX 11 session able to reference only Microsoft.Data.Services and use the toolkit without any compilation errors?
As expected, the answer is to recompile the source yourself against the CTP binaries.
http://wcfdstoolkit.codeplex.com/workitem/13
I ended up doing that myself, after watching and rewatching the MIX11 session a thousand times following whatever Jonathan did down to the last detail.

What is the last version of nhibernate that supports .Net Framework 2?

What is the last version of nhibernate that supports .Net Framework 2 ? and is there a big difference between dealing with it and dealing with last version that supports .Net 3.5 ?
Note:
The series NH2.1.x is the last whose
target is .NET2.0
NHibernate 3 Alpha (full .NET Framework 3.5 support):
With the 3.0.0 release, NHibernate
includes support for LINQ, along with
additional features such as:
Along with a long list of bug fixes
and improvements, it has several new
features including a new strongly
typed criteria API called QueryOver;
lazy loading of columns; alias
delimiting in generated SQL; and
support for DetachedCriteria within
IStatelessSession. The new release
also brings improved support for LINQ,
overcoming the HQL limitations of the
previous provider.
Upgrading users should be aware that
one of the fixes means that null
values in dictionaries are no longer
silently ignored, which has the
potential to break existing
application code.