I want To create Feature Class in an enterprise geodatabase with ArcObjects. This is a small part of our plugin. In our case, we want to create a Feature Class in the database Identical to the layer that is in TOC. It creates that successfully, but when we add it to the TOC and want to edit it, ArcMap returns the message This data is not editable
. The user has full permission.
It is possible to create Feature Class manually in geodatabase With a database Connection in the Catalog tree; It was successfully created and it is editable and I can Register it as versioned. But When I try to create a feature Class with Arcobjects it returns No editable Layer
and I can't edit the feature Class.
SQL Server in use: Microsoft SQL Server 2008 Express Edition (64-bit) , version of ArcGIS in use: 10.2.2, the license level of ArcGIS: Advanced (ArcInfo) Concurrent Use.
This is our code:
Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SqlWorkspaceFactory");
IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
IPropertySet connectionProps = new PropertySetClass();
connectionProps.SetProperty("SERVER", "gSERVER");
connectionProps.SetProperty("INSTANCE", "sde:sqlserver:gSERVER-pc");
connectionProps.SetProperty("DATABASE", "Ga");
connectionProps.SetProperty("DBCLIENT", "SQLServer");
connectionProps.SetProperty("SERVERINSTANCE", "gSERVER-pc\\sqlraSERVER");
connectionProps.SetProperty("AUTHENTICATION_MODE", "OSA");
IFeatureWorkspace workspace = (IFeatureWorkspace)workspaceFactory.Open(connectionProps, 0);
IMxDocument mxd = ArcMap.Application.Document as IMxDocument;
IMap map = mxd.FocusMap;
ILayer layer = map.Layer[0] as ILayer;
IFeatureLayer featurlayer = layer as IFeatureLayer;
IFeatureClass fc = featurlayer.FeatureClass;
IWorkspace wrk = workspace as IWorkspace;
IFields fields = featurlayer.FeatureClass.Fields;
IFeatureWorkspace hhj = workspace as IFeatureWorkspace;
IFeatureClass outputFeatClass = hhj.CreateFeatureClass(featurlayer.Name, fields, featurlayer.FeatureClass.CLSID, null, featurlayer.FeatureClass.FeatureType, "SHAPE", "");