I inherited a project (ASP.NET Web Forms) to update/upgrade. The project works just fine in VS 2013 when I run debug, but when I add a table to the SQL DB and "Update model from database" EF (4.0) is returning a bunch of errors like:
Error 34 Error 113: Multiplicity is not valid in Role 'Event' in relationship 'FK_FinanceInvoice_Events'. Because all the properties in the Dependent Role are nullable, multiplicity of the Principal Role must be '0..1'.
And it doesn't add the table to my model until I fix these errors, but if I change the Multiplicity setting (as some posts suggests to do) multiple other errors are coming up.
The thing is that the system and the EF Model works perfectly until I try to update it.
I also tried to create the model first and the "Generate DB", but this would drop the entire DB, and I cannot do that as it has lots of data in it.
One thing I noticed is that the Model.edmx does not have the .tt and context.tt files (I wanted to post a pic of my Solution Explorer, but I don't have enough reputation points). Is there a reason why these 2 files are missing from my model?
The second issue is that the database I need to update is in production and full of existing data.
I would greatly appreciate it if someone could point me to the right direction. Thank you!
EDIT: Jim Wooley suggested that the our DataModel was maybe created before T4, I don't know enough to find that out. Here is the content of the designer.cs file attached to the .edmx. Hopefully someone can tell me how it was created and how to update/modify the database and model
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Data.EntityClient;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Linq;
using System.Runtime.Serialization;
using System.Xml.Serialization;
[assembly: EdmSchemaAttribute()]
#region EDM Relationship Metadata
[assembly: EdmRelationshipAttribute("EMSDataModel", "FK_ActivityLogs_Log", "UserLog", System.Data.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne, typeof(EMS.Data.UserLog), "ActivityLog", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(EMS.Data.ActivityLog), true)]
//The rest i removed for brevity
namespace EMS.Data
{
#region Contexts
/// <summary>
/// No Metadata Documentation available.
/// </summary>
public partial class EMSDataModelContainer : ObjectContext
//The rest i removed for brevity
#region Entities
/// <summary>
/// No Metadata Documentation available.
/// </summary>
[EdmEntityTypeAttribute(NamespaceName="EMSDataModel", Name="AccommodationDetail")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class AccommodationDetail : EntityObject
//The rest i removed for brevity
#region ComplexTypes
/// <summary>
/// No Metadata Documentation available.
/// </summary>
[EdmComplexTypeAttribute(NamespaceName="EMSDataModel", Name="CheckCityExists_Result")]
[DataContractAttribute(IsReference=true)]
[Serializable()]
public partial class CheckCityExists_Result : ComplexObject
//The rest i removed for brevity
}
I hope someone can redirect me to making changes to the production database and consequently the model.
EDIT: I am using Visual Studio 2013 and this post didn't work for me How to Use Entity Framework 4 with Visual Studio 2013