Entity Developer supports integration with Visual Studio refactoring that enables renaming of model objects. For example, when renaming an entity or complex type, refactoring will ensure that any references to that class are renamed across your solution. Refactoring is applicable to namespaces, classes and complex types as well as their properties, enums and their members; for LinqConnect and Entity Framework models it also applies to the context class and its properties.
Refactoring starts after you save your project. In case any conflicts occur, refactoring will not be performed.
Note |
Refactoring is available only in Entity Developer Visual Studio add-in. |
For the purpose of the following example that illustrates refactoring operation, we create the Employee class in the model; the code we get is as follows:
NorthwindModel.NorthwindEntities context = new NorthwindModel.NorthwindEntities();
Employee emp = context.Employees.First();
Console.Write(emp.Address);
Then we make the following changes in the model:
• | rename the class from Employee to EmployeeEntity; |
• | rename class namespace from NorthwindModel to NorthwindNamespace; |
• | rename context namespace from NorthwindEntities to NorthwindContext; |
• | and rename the Address property to EmployeeAddress. |
After this we save the project and the code changes as follows:
NorthwindNamespace.NorthwindContext context = new NorthwindNamespace.NorthwindContext();
EmployeeEntity emp = context.EmployeeEntities.First();
Console.Write(emp.EmployeeAddress);
By default, refactoring is enabled, but it can be disabled for the sake of, for example, performance.
|