Auto Ad Code

Showing posts with label edmx. Show all posts
Showing posts with label edmx. Show all posts

Thursday, August 9, 2012

No mapping specified for the following EntitySet/AssociationSet

You can get this error when you have generated your Entity Model from a database.
This error means that due to any issue (update/delete etc) the Entity mappings are not same as the Database.

Solution

There can be seen many solutions to this problem over internet but the best solution as far as I know is
1. Double Click the edmx file to open the Entity Model in design view.
2. Press Ctrl A to select all objects within Entity Model.
3. Now press Delete to delete all objects.
4. Again generate your Entity model from Database using "Update Model from Database" option given in context menu (Right Click).
5. All done.

Hope this will help.


Happy Coding :)

Tuesday, June 5, 2012

The version of SQL Server in use does not support datatype 'datetime2' [SOLVED]

While using the Enitity framework you can come across the following error.
The version of SQL Server in use does not support datatype 'datetime2'
You must have checked your Database tables that if you have set datatype datetime2 for some field and I am sure you didn't find any of such field.
Okay, the problem is with the entity framework and not with the SQL Server.

Here is the Solution
1. Open your EDMX file in XML Editor or any file editor (like notepad).
2. Search for ProviderManifestToken in the file (it should be in top 7-8 lines)
3. It will be having the value 2008 (or may be 2010 in some cases).
4. Change the value from 2008 (or 2010) to 2005.
5. Save the file.
6. Run your code.
7. Hope the issue is not there any more.