setting modifier value on entity is read only

Jul 23, 2012 at 10:10 AM

i am not able to set the createdby property value from code . it says its not accessible.

how do i set its value . Is there a global setting where i can set the modifier and it gets picked up automatically , like there was in NHDAL.



 var item1 = new BaseModel();         

item1.Field1 = "dd11s";     

item1.Field2 = "sdsa"; 

item1.CreatedBy = "me";  // error - is read only






Aug 1, 2012 at 10:59 PM

This is the modifer. You set this when you declare a context. Create a "ContextStartup" object and pass it into the constructor of the context. It will be used for all CreatedBy and ModifiedBy fields.


var startup = new ContextStartup("user1");
using (var context = new NorthwindEntities(startup, "server=localhost;database=sakila3;uid=sa;pwd=secret;"))

Aug 2, 2012 at 7:56 PM

great. Thanks.

Nov 16, 2012 at 5:50 PM
Edited Nov 16, 2012 at 5:52 PM

I am currently stuck in 4.1.210 Land and cannot for the life of me find a constructor that takes more than one parameter.

Is there anyway in this version to specify both commands.


I am stuck here until I can upgrade the rest of my solution to EFDAL.

Nov 16, 2012 at 9:00 PM

In case anyone is curious I made the following function in the PROJECTNameEntities.cs class of the EFDAL

/// <summary>
        /// Create one with the connection string and modifier.
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="modifier"></param>
        public PROJECTNAMEEntities(string connectionString, string modifier) :
            base(connectionString, "PRJECTNAMEEntities")
            _contextStartup = new ContextStartup(modifier);

I don't know if it is still applicable in the 5.0 Line or not.