Le réseau pour les développeurs >
Forums - Accueil
>
LINQ to SQL (Pre-Release)
>
Linq2Sql Shared Common Table causes Entity name conflict when using Dynamic Data
Linq2Sql Shared Common Table causes Entity name conflict when using Dynamic Data
- I have project where I am create Linq 2 Sql files for each group of business objects. For this case these groups are People and Users. There is a relationship of a User to Person but a person can stand alone. The issue is that both of these Linq files has a reference to table named dbo.People. When I try to run this project in a Dynamic Data project I get the following error.
The name for entity 'openPlat.Models.PeopleTables.People' in context 'openPlat.Models.PeopleTables.PeopleDataContext' conflicts with the name for the entity 'openPlat.Models.UserTables.People' in context 'openPlat.Models.UserTables.UsersDataContext'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: The name for entity 'openPlat.Models.PeopleTables.People' in context 'openPlat.Models.PeopleTables.PeopleDataContext' conflicts with the name for the entity 'openPlat.Models.UserTables.People' in context 'openPlat.Models.UserTables.UsersDataContext'.
Source Error:
Line 28: // class in your application. Line 29: model.RegisterContext(typeof(openPlat.Models.UserTables.UsersDataContext), new ContextConfiguration() { ScaffoldAllTables = true }); Line 30: model.RegisterContext(typeof(openPlat.Models.PeopleTables.PeopleDataContext), new ContextConfiguration() { ScaffoldAllTables = true }); Line 31: Line 32: // The following statement supports separate-page mode, where the List, Detail, Insert, and
Source File: H:\Users\Owner\Documents\Visual Studio 2008\Projects\openPlat\openPlat\Global.asax.cs Line: 30
Stack Trace:
[ArgumentException: The name for entity 'openPlat.Models.PeopleTables.People' in context 'openPlat.Models.PeopleTables.PeopleDataContext' conflicts with the name for the entity 'openPlat.Models.UserTables.People' in context 'openPlat.Models.UserTables.UsersDataContext'.] System.Web.DynamicData.MetaModel.CheckTableNameConflict(MetaTable table, String nameOverride, List`1 tablesToInitialize) +159679 System.Web.DynamicData.MetaModel.RegisterContext(DataModelProvider dataModelProvider, ContextConfiguration configuration) +758 System.Web.DynamicData.MetaModel.RegisterContext(Func`1 contextFactory, ContextConfiguration configuration) +359 System.Web.DynamicData.MetaModel.RegisterContext(Type contextType, ContextConfiguration configuration) +79 openPlat.Global.RegisterRoutes(RouteCollection routes) in H:\Users\Owner\Documents\Visual Studio 2008\Projects\openPlat\openPlat\Global.asax.cs:30 openPlat.Global.Application_Start(Object sender, EventArgs e) in H:\Users\Owner\Documents\Visual Studio 2008\Projects\openPlat\openPlat\Global.asax.cs:59 [InvalidOperationException: An error occurred during model registration and this operation cannot be performed.] System.Web.DynamicData.MetaModel.CheckForRegistrationException() +160119 System.Web.DynamicData.MetaModel.get_Default() +4 openPlat._Default.Page_Load(Object sender, EventArgs e) in H:\Users\Owner\Documents\Visual Studio 2008\Projects\openPlat\openPlat\Default.aspx.cs:21 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +50 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Any advice on how to handle using a table in multiple Linq 2 Sql files would be greatly appreciated.- DéplacéZhi-Xin YeMSFTmercredi 27 mai 2009 12:49not a BCL question (From:.NET Base Class Library)
Réponses
- The problem is a naming conflict between types in 2 different contexts. To get around this you can rename one of the classes specifying the TableNameAttribute on your entity.
- Marqué comme réponseDamien Guard - MSFTModérateurmardi 2 juin 2009 17:44
Toutes les réponses
The Context is Haved these's models
You can look the Context Class
James.Ying- This would seem to be part of the implementation of Dynamic Data requiring unique naming so you might want to also ping that team via their forums.[)amien
- The problem is a naming conflict between types in 2 different contexts. To get around this you can rename one of the classes specifying the TableNameAttribute on your entity.
- Marqué comme réponseDamien Guard - MSFTModérateurmardi 2 juin 2009 17:44

