Quantcast
Channel: EntityFramework Reverse POCO Code First Generator
Viewing all 1642 articles
Browse latest View live

Updated Wiki: What's new

$
0
0

Whats coming in the next release:

  1. { get; internal set; } for stored generated fields has been changed to { get; set; }. In some situations you may want to assign it manually, and another when serializing across a WCF service. The ID is lost when serializing because it was marked internal. Thanks to fjrodriguez.

Whats new in v2.12.3:

  1. Remove use of [GeneratedCodeAttribute] where not necessary.
  2. Case 108. Include the schema when calling stored procedures. Thanks to emdadgar2.
  3. Case 109. Nullable uniqueidentifier with default value generates exception. Thanks tomarkuspeter.
  4. Case 107. Stored procedure return column name tidy up could bring all Null value. Thanks todisanxian.
  5. Case 106. Add support for async methods. Thanks to youngcm2.
  6. Changed the stored procedure parameters to be nullable. Thanks to Suraj Ramalingam.
  7. Case 110. Do not remove stored procedure where it has no return fields. Thanks toemdadgar2.

Whats new in v2.12.1:

  1. Case 101. SQL Server compact connection string only looks in current project. It now looks in all project paths for the SDF file, in a similar way to finding the app.config file for the connection string.
  2. Much faster TableSQL. Query plan cost is 97% vs 3%. Thanks to Glenn Orr.
  3. Much faster ForeignKeySQL. Query plan cost is 71% vs 29%.
  4. Unique indexes are now checked for. Previously, for tables without primary keys, all the NOT NULL columns used to be marked as a primary key. Now, if the table has a unique index, these unique index columns are used instead. However, the columns are still checked for being NOT NULL as entity framework will not allow a primary key to be made up of a column which can be NULLable.
  5. MakeClassesPartial flag now adds partial keyword to the stored procedure model classes.
  6. Added AdditionalContextInterfaceItems array to allow adding of extra functions to the db context interface.
  7. Fix schema prepending for Stored Procedures. Thanks to Emanov.
  8. Fix bug in MigrationStrategy when set to CreateDatabaseIfNotExists or DropCreateDatabaseIfModelChanges. Thanks toWill.
  9. Case 102. Stored procedures with no input parameters and all columns are nullable views cannot get populated in .cs. Thanks todisanxian.
  10. Calls to stored procedures are now placed in [square brackets] in case there are spaces in its name.
  11. Case 103. Check for column name C# reserved word name clashes. Thanks to swago.
  12. Do not include foreign keys which use composite keys.

Whats new in v2.11.0:

  1. Case 61. Allow excluding/modifying columns. Also permits you to run a function against each column to optionally modify the column properties (eg. to tweak the name of the generated property etc). Thanks toDavid Gardiner.
  2. Case 99. Add ability to specify additional using namespaces. Thanks to rorourke.
  3. Case 100. Apply GeneratedCodeAttribute to generated code. Thanks to David Gardiner.

Whats new in v2.10.2:

  1. Case 93. Merge logic for foreignKey column matching, previously .col=null was possible. Thanks toAHewgill.
  2. StoredProcs that return nullable binary types generate invalid "ReturnModel" code. Thanks toWallyHDisplayName.
  3. Case 96. Add a default for getutcdate(). Thanks to mbargar13.
  4. Case 94. Missing "using DatabaseGeneratedOption = System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption;" when targeting Framework 4.5. Thanks toalexdeblasis.
  5. StoredProcedureRename was being ignored. Thanks to slyCzar.
  6. Case 98. Corrected bridge table issue. Thanks to simooo985.

Whats new in v2.10.1:

  1. Stored Procedure arguments that are C# reserved keywords need escaping. Thanks toJimstr.
  2. Make mapping variables consistent during name clashes. An an edge case could cause different names for the reverse navigation as compared to the Map during name clashes. Thanks toFJRodriguez.
  3. Fix indentation when MakeClassesPartial is set.

Whats new in v2.10.0:

  1. Auto Migrations. To enable set MigrationConfigurationFileName to a class name, "MyDbContextDBMigrationConfiguration" for example. This enabled Entity Framework to update the schema when it is deployed in production. Thanks toFJRodriguez.
  2. Remove use of uses_native_compilation column in Stored Procedure SQL to support older database (< 2014). Thanks toNicholas Head.

Whats new in v2.9.1:

  1. GetSqlDbType was missing some types (nvarchar, and uniqueidentifier). Thanks toWally.
  2. Add in "using System.Linq" if Elements.StoredProcedures declared and not Elements.Context. Thanks toWally.

Whats new in v2.9.0:

  1. Stored procedure support !
    • This includes the ability to retrieve the RESULT from stored procs, as well as the data. A result of 0 means success, any other value is an error.
    • Include stubs for the stored procs in the FakeDbContext.
  2. Sort contents of HasForeignKey(...) by foreign key ordinal.
  3. Prevent creating maps where the left and right side of the map are the same table.
  4. Use a try/catch for WCF projects. Thanks to FJRodriguez.
  5. Include examples of CustomPluralizationEntry. Thanks to Carrie Kroutil.
  6. Allow for manual setting of the targeted .Net framework version.

Whats new in v2.8.3:

  1. Added new setting IncludeQueryTraceOn9481Flag so that you are now in control if "OPTION (QUERYTRACEON 9481)" is appended to the SQL. SqlServer 2014 is known to appear frozen / take a long time when this file is saved. If it does, set this to true (however you will also need elevated privileges).
  2. Added new setting DbContextBaseClass. You can now specify what the base class for your DbContext class is. For example ASP.NET Identity use "IdentityDbContext<ApplicationUser>", or even go so far as a custom: IdentityDbContext<CustomUser, CustomRole, int, CustomUserLogin, CustomUserRole, CustomUserClaim>. Thanks toParag Shravagi.
  3. Fixed bug: IndexOutOfRangeException thrown inside GetCurrentProject. Thanks toDavid Gardiner.
    https://efreversepoco.codeplex.com/workitem/85

Whats new in v2.8.2:

  1. This update is required to fix a problem with Sql Server 2014 as it freezes when obtaining the Foreign Keys. See here for more info. The solution was to add OPTION (QUERYTRACEON 9481). Thanks to@ErikEJ for the solution.
    Using this option flag needs a higher SQL privilege, so you may experience:
    User 'Your.Name' does not have permission to run DBCC TRACEON.
    More info (requires sysadmin rights) http://spaghettidba.com/2013/02/08/using-querytraceon-in-plan-guides/ 

Whats new in v2.8.1:

  1. Bug fix: If property had _ appended, and is used as key, it breaks template generation. Thanks toNicholas Head.

Whats new in v2.8.0:

  1. Added a new flag: AddUnitTestingDbContext. If true, this will create a Fake DbContext and a FakeDbSet<T>. This will allow easy unit testing. Can't believe I never added this sooner. See the documentation Unit Testing.

Whats new in v2.7.0:

  1. Fixed bug: Missing schema specification in ManyToMany tables. Thanks to Vtanman & Snajahi.
  2. Add a timeout when obtaining the schema info from a slow database. Thanks to DotNetWise.
  3. Changed table renaming to use a function. Thanks to DotNetWise.

Whats new in v2.6.3:

  1. Add IsUnicode(false) for the char/varchar columns. Thanks to Naomi N.
  2. Rollback a feature added in 2.5.1: For database types such as Numeric(17,0), the C# type should resolve to something in the "int" family. Thanks toSimmered.

Whats new in v2.6.2:

  1. Include another namespace if Target framework is not 4.0. Thanks to NazmulRockOn.
  2. CR/LF in extended properties caused errors. Thanks to Simmered.
  3. Use IsFixedLength() for char/nchar types. Thanks to Naomi N.

Whats new in v2.6.1:

  1. Added the same extended properties comments facility for SQL CE. Thanks to @ErikEJ

Whats new in v2.6.0:

  1. It now reads the extended properties and can add them to the poco classes in comments. See the new IncludeExtendedPropertyComments flag which is an enumeration of
[Flags]
public enum ExtendedPropertyCommentsStyle
{
  None,
  InSummaryBlock,
  AtEndOfField
};
  • ExtendedPropertyCommentsStyle.None: No extended properties are shown.
  • ExtendedPropertyCommentsStyle.InSummaryBlock: extended properties are shown above field in a ///<summary> block.
  • ExtendedPropertyCommentsStyle.AtEndOfField: extended properties are shown at the end of the field in a comment block.

The IncludeComments flag is completely independent to IncludeExtendedPropertyComments.

If you want completely comment free generate code, set IncludeComments = false, and IncludeExtendedPropertyComments = ExtendedPropertyCommentsStyle.None;

Whats new in v2.5.1:

  1. Move the call to tables.SetPrimaryKeys(); higher up. This allows support of tables with no primary keys to be able to be used. Thanks toJaved.
  2. For database types such as Numeric(17,0), the C# type should resolve to something in the "int" family. Thanks tosimmered.

Whats new in v2.5.0:

  1. Added option to strip and alter table names. Such as tblOrders to Orders, AB_Shipments to Shipments, etc. See Table renaming section.
  2. Added ability to switch off the Pluralization service.
  3. Added ability to use other Pluralization services, such as the SpanishPluralizationService as provided in the "EF6.Contrib" Nuget Package. If you are to use the SpanishPluralizationService, add the following to the top of your database.tt file: <#@ assembly name="C:\<Your path here>\packages\EF6.Contrib.1.0.5\lib\net45\EntityFramework.Contrib.dll" #> Changing the path to where your DLL is situated.

Whats new in v2.4.1:

  1.  Fixed bug: When using .HasForeignKey(...) for multi-column keys, the columns should be listed in ordinal order. Thanks toScott Hodges.

Whats new in v2.4.0

  1. Removed use of System.Data.Entity.DLL from the installation template as it is no longer required for EF 6.
  2. Moved spatial types from System.Data.Spatial to System.Data.Entity.Spatial for EF 6.
  3. Singular names and camel casing configuration were accidentally combined by using the UseCamelCase boolean. Thanks toRune Gulbrandsen.
  4. Added new flag IncludeComments. This controls the generation of comments in the output.
  5. Fixed bug in constructor where a UNIQUEIDENTIFIER column had default value. Thanks togonglei.

Whats new in v2.3.2

  1. Singularize one-to-one Reverse Navigation. Thanks to StormRider.
  2. Bugfix for IsRowVersion() for timestamp columns. Thanks to StormRider.
  3. Do not append "m" to decimal value in poco ctor if default contains an unparsable value.

Whats new in v2.3.0:

  1. SQL Server Compact 4.0 support. Thanks to ErikEJ.

Whats new in v2.2.1:

  1. Add strings to be allowed as computed columns. Thanks to JBJBJB and BrhineScot.
  2. Now includes callbacks during code generation. This means you can add attributes to classes, specify a base class, specify custom code within the class, and finally a call back for each column within the class. Thanks toSimplyFoolish
  3. OData doesn't support entities with geometery/geography types. Provided a flag to turn these off if entities are being generated from ODATA.  Thanks toSimplyFoolish. Flag is called DisableGeographyTypes.
  4. Fixed bug with the Pluralisation service. If your current culture was not en, then it would throw an exception. Thanks toErikEJ.

Whats new in v2.2.0:

  1. Now uses the .Net Pluralization service. Thanks to James Manning.
  2. Bug fixed when you have foreign keys between two tables where the FK/PK columns have spaces in the column name. Thanks toColin Smith.
  3. Bug fixed. Solution Folders are not searched for config settings. Thanks to scaftw.
  4. Generate navigation property based on FK name. If there are two FK links to a table, the second link would appear as linkName1. This is now detected and both the FK properties will make use of the FK name. If only one FK is used, then the FK name is not appended to the table name. Thanks to saber_solomon.
  5. Sort the generated Reverse navigation and foriegn keys in POCO classes.

Whats new in v2.1.0:

  1. Fixed bug if default constraint was not in expected format. Thanks to Filipe Fujiy.
  2. Now detects name clashes with C# keywords.
  3. Added "System." to DateTime.Now(), etc to prevent clashes with table field names.
  4. "Configuration" class names are now configurable as "Mapping", "Map", etc.
  5. Added support for Spatial.DbGeometry and Spatial.DbGeography. Thanks to Simply Foolish andJorge Bustos.
  6. Can now have custom collection type for Navigation Properties. "ObservableCollection" for example. Thanks to Simply Foolish.

Whats new in v2.0:

  1. Fixed issue when running 'Transform All T4 Templates' from Visual Studio Build Menu.Thanks to JRoselle.
  2. Changing mappings during runtime is not possible/expensive. A specific DbModelBuilder can be used for each needed database schema.Thanks to meixger.
  3. Added ability to detect and use .IsRowVersion().
  4. Added many-to-many mappings. The generated code now includes calls to .Map(). Therefore the generated code will be different to what you had previously in v1 if you have many-to-many table mappings in your database. Hence the revision change to v2.0.0 as I'm using semantic versioning.

Whats new in v1.12:

  1. VARBINARY(MAX) is now correctly assigned to byte[]. Thanks to Luke91577.
  2. Extending partial class support. Allow specification of file extension for partial classes (i.e. ".generated.cs").Thanks to AB_dreeve.
  3. Fixes issues when targeting .NET 4. .NET 4.0 doesn't include the System.ComponentModel.DataAnnotations.Schema namespace, allow specification of TargetFrameworkVersion.Thanks to AB_dreeve.

Whats new in v1.11:

  1. Including views is now working. For a view to be included, at least one column must not be nullable.Thanks to Delmo Carruzzo.
  2. Added selective generation of components (Poco, Context, UnitOfWork, PocoConfiguration). You can now build entities in your Model project, and context, configuration, unit of work in your Data project. Thanks to kscelfo.
  3. Added PrependSchemaName flag. You can now control if the schema name is prepended to the table name. Thanks to kscelfo.

Whats new in v1.10:

  1. Added UseCamelCase flag to the tt file. You can now control if you want your table and column names CamelCase or left alone: i.e. FieldPersonOrder or field_person_order

Whats new in v1.9.2:

  1. Removed the Linq de-duplication code as it is now being done in SQL. The Linq version did not include the schema name when de-duplicating FK's.

Whats new in v1.9.1:

  1. Added DISTICT to the foreign key SQL. This prevents duplicates from appearing.
    They can appear with SQL such as:
    ALTERTABLE [Mars].[Table2] WITHCHECKADDCONSTRAINT [FK_Table2_Table1]
    FOREIGNKEY([Table1Id]) REFERENCES [Mars].[Table1] ([Id]) ALTERTABLE [Mars].[Table2] CHECKCONSTRAINT [FK_Table2_Table1]

Whats new in v1.9.0:

  1. It now has the ability to read connection strings from other config files/projects.
    It starts by looking at the local project for the named connection string in the following files:
    • app.config
    • web.config
    • app.config.transform
    • web.config.transform
    • or edit the above list in the .tt and specify which file(s) to use
    If not found, it then looks for those files in all the projects within the solution.

Whats new in v1.8.0:

  1. Can now optionally generate separate files. See the new boolean flag GenerateSeparateFiles.
  2. Removed the hard coded 300 second timeout. The timeout can be specified in the connection string.

Whats new in v1.7.1:

  1. Add support for DateTime2
  2. Add support for UnitOfWork and the repository pattern. This means you can now unit test your repositories. See the source code for examples.
  3. Add IDisposable to db context.

Whats new in v1.7.0:

  1. Add .HasPrecision(precision, scale) for fields that have scale. Thanks to @choudeshell

Whats new in v1.6.0:

  1. Enhance ReadSchema performance with early table exclusion.
  2. Now supports columns with symbols and punctuation.
  3. Handles decimal default values.

Whats new in v1.5.1:

  1. A bugfix for WCF. See issue https://efreversepoco.codeplex.com/workitem/4

Whats new in v1.5.0:

  1. Ability to add WCF(DataMember, DataContract attributes) support on Entity. Requested by spatemp

Whats new in v1.4.1:

  1. Foreign keys are only included if they point to a primary key.

Whats new in v1.4.0:

  1. If a field has a default contrainst of GetDate(), add DateTime.Now() in the ctor for the field.
  2. Add support for the datetimeoffset type, including support for the default constraint sysdatetimeoffset().
  3. Add Resharper naming comments.
  4. Mappings should be marked internal. Requested by Hobbes Pirakitti

New Post: The way to choose objects included in the model

$
0
0
This is still on my todo list. It has not been forgotten about :-)

New Post: The way to choose objects included in the model

$
0
0
Simon,

I understand. It can be improved to support column level filter, but it's not neccessary for my case. So I didn't realize it.

Created Unassigned: Problem generating TT file [111]

$
0
0
Hi,

I am getting this VS error when generating the tt file. Please help

Thanks


Error 1 Running transformation: System.ArgumentException: The path is not of a legal form.
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetDirectoryName(String path)
at Microsoft.VisualStudio.TextTemplating3A2EBC5DE9150D6E1D5F7D9A0E7080395B39B7DA627A5A1DB97EA78032215253EBAEF8212B4F02F84B1D921B104797195E3C13EEC9C3A0BDC1064D942860F3EF.GeneratedTextTransformation.GetDbProviderFactory()
at Microsoft.VisualStudio.TextTemplating3A2EBC5DE9150D6E1D5F7D9A0E7080395B39B7DA627A5A1DB97EA78032215253EBAEF8212B4F02F84B1D921B104797195E3C13EEC9C3A0BDC1064D942860F3EF.GeneratedTextTransformation.TransformText() c:\temp\WebApplication1\WebApplication1\TT\Database1.tt 1 1 WebApplication1



Commented Unassigned: Problem generating TT file [111]

$
0
0
Hi,

I am getting this VS error when generating the tt file. Please help

Thanks


Error 1 Running transformation: System.ArgumentException: The path is not of a legal form.
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetDirectoryName(String path)
at Microsoft.VisualStudio.TextTemplating3A2EBC5DE9150D6E1D5F7D9A0E7080395B39B7DA627A5A1DB97EA78032215253EBAEF8212B4F02F84B1D921B104797195E3C13EEC9C3A0BDC1064D942860F3EF.GeneratedTextTransformation.GetDbProviderFactory()
at Microsoft.VisualStudio.TextTemplating3A2EBC5DE9150D6E1D5F7D9A0E7080395B39B7DA627A5A1DB97EA78032215253EBAEF8212B4F02F84B1D921B104797195E3C13EEC9C3A0BDC1064D942860F3EF.GeneratedTextTransformation.TransformText() c:\temp\WebApplication1\WebApplication1\TT\Database1.tt 1 1 WebApplication1



Comments: It is this line of code that fails: string solutionPath = Path.GetDirectoryName(GetSolution().FileName) + "\\"; I encountered same issue in my Toolbox add-in - never found a solid solution, other than error catching

Commented Unassigned: MVC Scaffolding error, GenerateSeparateFiles=false [104]

$
0
0
IN VS.net 2013, when I try running the Add New Scaffolded Item -> "MVC5 Controller with views, using Entity Framework" and the model was generated using the single file option (GenerateSeparateFiles=false), I get the following Error:
"There was an error running the selected code generator: Object reference not set to an instance of an object."

Running the same model as multiple files seems ok.

Anyone else seeing this issue?

Thanks!
Comments: I am seeing the same issue.

Commented Task: Microsoft suggest to use DbSet instead of IDbSet [89]

$
0
0
Related to discussion: https://efreversepoco.codeplex.com/discussions/568503

I would like to move this as an issue because IDbSet is a deprecated interface, and this api will not be updated anymore, so any new functionality will not be added in the IDbSet, but only in DbSet, like the "AddRange":

Took directly from the IDbSet official code comments:
"
IDbSet<TEntity> was originally intended to allow creation of test doubles (mocks or fakes) for DbSet<TEntity>. However, this approach has issues in that adding new members to an interface breaks existing code that already implements the interface without the new members. Therefore, starting with EF6, no new members will be added to this interface and it is recommended that DbSet<TEntity> be used as the base class for test doubles.
"

Testing with a mocking framework (EF6 onwards): https://msdn.microsoft.com/en-us/data/dn314429

Testing with your own test doubles (EF6 onwards): https://msdn.microsoft.com/en-us/data/dn314431
Comments: DbSet also has an AddRange function, which can give a significant improvement in performance when inserting a large number of objects. This is because it only calls DetectChanges once before all the objects are added vs calling it for every object when using Add.

Commented Unassigned: Unique Indices [59]

$
0
0
It seems there is no option to identify unique keys of a table in database in generated configuration mapping classes.
For example


```
CREATE TABLE [dbo].[FinancialInstitutionOffice](
[Code] [uniqueidentifier] NOT NULL,
[FinancialInstitutionCode] [uniqueidentifier] NOT NULL,
[OfficeName] [nvarchar](200) NULL,
...

)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY],
CONSTRAINT [UniqueOfficeName_FinancialInstitutionOffice] UNIQUE NONCLUSTERED
(
[FinancialInstitutionCode] ASC,
[OfficeName] ASC,
)
```

The generated code does not show the constraint of above table.
Comments: I have already added support for unique constraints. In the case above, the OfficeName is NULLable, which is not allowed in entity framework. If I added this as a primary key you would get the following error. ``` OfficeName: Nullable: Key part 'OfficeName' for type 'FinancialInstitutionOffice' is not valid. All parts of the key must be non-nullable. ```

Closed Unassigned: Unique Indices [59]

$
0
0
It seems there is no option to identify unique keys of a table in database in generated configuration mapping classes.
For example


```
CREATE TABLE [dbo].[FinancialInstitutionOffice](
[Code] [uniqueidentifier] NOT NULL,
[FinancialInstitutionCode] [uniqueidentifier] NOT NULL,
[OfficeName] [nvarchar](200) NULL,
...

)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY],
CONSTRAINT [UniqueOfficeName_FinancialInstitutionOffice] UNIQUE NONCLUSTERED
(
[FinancialInstitutionCode] ASC,
[OfficeName] ASC,
)
```

The generated code does not show the constraint of above table.
Comments: Generator supports unique indices.

New Post: Some Foreign Keys are not generated

$
0
0
Hallo,
im using Version.2.12.3

some Foreign Keys are not generated.

Example SQL
CREATE TABLE [dbo].[Company](
    [coID] [int] IDENTITY(1,1) NOT NULL,
    [cocogID] [int] NULL,
    [cocuID] [int] NULL,
    [coName] [nvarchar](255) NULL,
    [coShortName] [nvarchar](50) NULL,
    [coHtmlName] [nvarchar](1000) NULL,
    [coEmployerNo] [nvarchar](50) NULL,
    [coValidFrom] [datetime] NULL,
    [coValidTo] [datetime] NULL,
    [coVatIdNo] [nvarchar](50) NULL,
    [coURL] [nvarchar](255) NULL,
    [coActive] [bit] NOT NULL CONSTRAINT [DFCompanyCoActive]  DEFAULT ((0)),
 CONSTRAINT [PK_Company] PRIMARY KEY CLUSTERED 
(
    [coID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Company]  WITH CHECK ADD  CONSTRAINT [FK_Company_CompanyGroup] FOREIGN KEY([cocogID])
REFERENCES [dbo].[CompanyGroup] ([cogID])
GO
ALTER TABLE [dbo].[Company]  WITH CHECK ADD  CONSTRAINT [FK_Company_Customers] FOREIGN KEY([cocogID])
REFERENCES [dbo].[Customers] ([custId])
generates to:

``` snip
// Company
[DataContract]
[GeneratedCodeAttribute("EF.Reverse.POCO.Generator", "2.12.3.0")]
public partial class Company : TravelProBaseEntity
{
    private int _coID;
    [DataMember(Order = 1, IsRequired = true)]
    public int coID { get { return _coID; } set { OnNotifyPropertyChanged(ref _coID, value); } } // coID (Primary key)

snip

    // Reverse navigation
    public virtual ICollection<AccountBookingGroup> AccountBookingGroups { get; set; } // AccountBookingGroups.FK_AccBookGrp_Company
snip

// Foreign keys
    public virtual Customer Customer { get; set; } // FK_Company_Customers
public Company()
    {
        coActive = false;
snip
...

Do you have any suggestions why the Foreign Key 'FK_Company_CompanyGroup' is not generated?

This results in Execution Errors on queriing the comanies Entitys.

Thanks

Christopher

I can Upload more Code if nedded.

Commented Unassigned: Adding classes for views [88]

$
0
0
Would it be possible to generate classes for SQL Server views and (optionally) table-valued functions?

It would be nice to be able to specify list of views to generate POCO classes for. These views may be based on several tables and use SQL Server scalar functions.

BTW, are you aware of some extra "script like" content on this page https://visualstudiogallery.msdn.microsoft.com/ee4fcff9-0c4c-4179-afd9-7a2fb90f5838 ?
Comments: I found a difference in the generated classes. When it's table-based, I see partial void InitializePartial(); and call to it from the constructor. For the view I only see properties. Why the InitializePartial() is not added when it's view based class?

New Post: Some Foreign Keys are not generated

$
0
0
Can you check if CompanyGroup.cogID is a PrimaryKey.
EntityFramework will only work with ForeignKeys that point to primary keys.

Source code checked in, #32e775fc5e3d

$
0
0
Tidy up code around processing unique indexes

Commented Unassigned: Adding classes for views [88]

$
0
0
Would it be possible to generate classes for SQL Server views and (optionally) table-valued functions?

It would be nice to be able to specify list of views to generate POCO classes for. These views may be based on several tables and use SQL Server scalar functions.

BTW, are you aware of some extra "script like" content on this page https://visualstudiogallery.msdn.microsoft.com/ee4fcff9-0c4c-4179-afd9-7a2fb90f5838 ?
Comments: There is another problem - I create a view which is used for counts. It uses CTE and UNPIVOT. The model is not being generated at all in this case.

Created Unassigned: Model is not generated for a complex view [112]

$
0
0
I have a view with the following code:

```
create view [dbo].[SiriusV_LicensesCount]
as
with cteLicenses as (
select sum(case when sp.is_test = 0 and sp.mode <> 9 then cast(sp.is_access as int) else 0 end) as AccessWare -- Not kiosk
, sum(case when sp.is_test = 0 then cast(sp.is_adv_inv as int) else 0 end) as AdvInventory
, sum( cast(sp.is_test as int)) as Test
from dbo.sales_pt sp where sp.hidden = 0)
select LicenseType, [Count]
from cteLicenses unpivot ([Count] for LicenseType in
(AccessWare, Test)
) unpvt
```

I removed some columns here for brevity. I found that the model class is not being created at all.

Do you know what is wrong - is it because all columns are calculated?

New Post: Some Foreign Keys are not generated

$
0
0
Hi,
This is a Primary Key.
In this Project we are using the EF Power Tools to generate the classes form db.
We want to move to your POCO Generator, to have more control of the generation. (pluralisatioen etc.)
CREATE TABLE [dbo].[CompanyGroup](
    [cogID] [int] IDENTITY(1,1) NOT NULL,
    [cogCompanyGroupName] [nvarchar](50) NULL,
    [cogValidFrom] [datetime] NULL,
    [cogValidTo] [datetime] NULL,
 CONSTRAINT [PK_CompanyGroup] PRIMARY KEY CLUSTERED 
(
    [cogID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
What else can I provide to solve this issue? DB-Schema?, old Entities from EFPower Tools?

Thanks

Christopher

Commented Feature: Error when using a DbContextBaseClass that does not implement a constructor [95]

$
0
0
If the DbContextBaseClass does not implement the constuctor:

```
public <#=DbContextName#>(string connectionString, System.Data.Entity.Infrastructure.DbCompiledModel model) : base(connectionString, model)
```

You get a compile error.

What about a condition over a configuration value? :)

Thanks!
Comments: I'm suffering from the same issue , is there any documentation,Example or Demo for how the DbContextBaseClass is intended to be used ? Thank You .

Closed Issue: Generate optional parameter information in sproc methods [91]

$
0
0
For stored procedures there is currently no handling of optional parameters; all parameters are indicated to be non-optional.

I've been trying to find a way to find this information, for instance for information_schema, but the best (and only working) solution is the big blob of SQL from this comment [http://stackoverflow.com/a/15827063](http://stackoverflow.com/a/15827063)

Quite the complex and error-prone way to get the information though.

Has this been discussed ?
Comments: I am going to close this for now as I've made all the parameters optional.

Created Unassigned: UseCamelCase and views [113]

$
0
0
We have set UseCamelCase = true in our tt file. The problem with this setting that it changes columns in the views as well. Say, I have column FBQuickService or PMSInterface and the resulting name is FbQuickService and PmsInterface. For the views I normally do name the columns the way I need them. I am wondering if it's possible to have a separate setting to still convert table columns, but preserve views' columns with their names?

Thanks in advance.

Created Unassigned: FakeDB Context navigation issue [114]

$
0
0
Hi,

I am using the Fake DB context for unit testing.

The problem I am facing is that I am not able to use the navigation properties, i.e.

I have two tables ParentTable and ChildTable.
ChildTable (ParentTableId) has foreign key relation to ParentTable (Id)

When I am trying to unit test my code saying

fakeDbContext.ChildTables.Include(c => c.ParentTable).ToList() returns null even though data is populated.

Can you please help me on this.
Viewing all 1642 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>