Quantcast
Channel: Entity Framework
Viewing all 10318 articles
Browse latest View live

Commented Unassigned: nullreferenceexception entity framework when table is null [2467]

$
0
0
hi all
im using entity framework 6.1.1 and code first And Use UnitOfWork

this is my unitofwork interface:

```
public interface IUnitOfWork
{

IDbSet<TEntity> Set<TEntity>() where TEntity : class;
}

```

this is my datacontext

```
public partial class myDataContext : DbContext, IDbContext
{
public new IDbSet<TEntity> Set<TEntity>() where TEntity : class
{
return base.Set<TEntity>();
}

1- public DbSet<ProductInventory> ProductInventories { get; set; }
2- public DbSet<ProductUnitDefain> ProductUnitDefains { get; set; }


}

```
this is Service Layer :

public readonly IDbSet<ProductUnitDefain> Entity;

im loading data with observablecollection and local metod for each model

```
public ObservableCollection<ProductUnitDefain> GetProductUnitDefainList(int product)
{
Entity.Where(x => product != null && x.Product == product).Load();
return new ObservableCollection<ProductUnitDefain>(Entity.Local);

}

public ObservableCollection<ProductInventory> GetProductInventoryList(int product)
{
Entity.Where(x => product != null && x.Product == product).Load();
return new ObservableCollection<ProductInventory>(Entity.Local);

}
```
i have 2 table in context:
ProductUnitDefain
and
ProductInventory

but exception error for ProductUnitDefain only
and ProductInventory worked perfectly

if table ProductUnitDefain is null
when Add Or Update record in to ProductUnitDefain exception nullreferenceexception in line:
return new ObservableCollection<ProductUnitDefain>(Entity.Local);
if ProductUnitDefain table have any record worked perfectly and no exception
how to resolve this problem
thanks




Comments: Hello, Could you please attach a small project which reproduces this issue? This would help us debug this further. Thanks

Commented Unassigned: TypesMatchByConvention NullReferenceException [2466]

$
0
0
I'm getting a NullReferenceException out of TypesMatchByConvention.

I've built a sample application from the same database that's having trouble and the sample application works fine, so I believe the problems have to do with upgrading from EF 4 to EF 6, but it's really hard to track down a bug from a NullReferenceException :/
Comments: I got it. Turns out it was a name conflict. I had an entity named "Part" and a library I was using had a class named "Part". I added a personal prefix to each of my entities and the problem has been solved. I hope you will find a way to give a more meaningful exception for this issue in the future. Or really, it shouldn't be a problem since the two classes were in different namespaces.

Commented Issue: DbMigrator.Update() is too slow even when the database is up to date [2292]

$
0
0
I have a project with 117 migrations for now and this count continues to grow.
On my developing machine, DbMigrator.Update() takes 3 seconds (3203 milliseconds to be precise) to finish, and the SQL Server database is already up to date.
I think there must be a way to reduce this time.
Comments: Hi deerchao, It sounds like something related to start-up in your specific environment and not migrations in particular. Perhaps you can profile your start-up code to determine where the time is being spent? Closing this issue. Cheers, Andrew.

Closed Issue: DbMigrator.Update() is too slow even when the database is up to date [2292]

$
0
0
I have a project with 117 migrations for now and this count continues to grow.
On my developing machine, DbMigrator.Update() takes 3 seconds (3203 milliseconds to be precise) to finish, and the SQL Server database is already up to date.
I think there must be a way to reduce this time.

Edited Issue: DbMigrator.Update() is too slow even when the database is up to date [2292]

$
0
0
I have a project with 117 migrations for now and this count continues to grow.
On my developing machine, DbMigrator.Update() takes 3 seconds (3203 milliseconds to be precise) to finish, and the SQL Server database is already up to date.
I think there must be a way to reduce this time.

Commented Unassigned: EF track back the detached entity after 30 minutes or so [2399]

$
0
0
Hi,

I was referred to this site by msdn.

Here is my original post from that site.

[http://social.msdn.microsoft.com/Forums/en-US/a939d0ed-7aec-4955-8aef-1c508ef07b89/multiplicity-constraint-violated-multiplicity-1-or-01?forum=adodotnetentityframework](http://social.msdn.microsoft.com/Forums/en-US/a939d0ed-7aec-4955-8aef-1c508ef07b89/multiplicity-constraint-violated-multiplicity-1-or-01?forum=adodotnetentityframework )



Any idea why EF track back the detached entity after 30 minutes or so?

Thanks
Comments: I'm not able to reproduce the issue with that information. If you could provide a sample project that would be very helpful. One thing to note, we recommend that you use DbContext is with a short lifespan so if you have something that takes longer than 30 minutes I recommend that you either detach the entity and then reattach on update, or save the entity key and then look up the object again to update when you want to save.

Commented Unassigned: Explicit Composite Index Only Inludes One of Two Specified Columns [2382]

$
0
0

EF 6.1.1, Code First, VS2013 Premium, C# Console Application. Targeting SQL Server 2014 Dev Ed.

Given this entity:

public class Child {
[Key, Column(Order=0)]
public int GrandParentId { get; set; }

[Key, Column(Order=1)]
[Index("IX_ParentId_Value", Order=1, IsUnique=true)]
public int ParentId { get; set; }

[Key, Column(Order=2)]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ChildId { get; set; }

[Required]
[Index("IX_ParentId_Value", Order=2, IsUnique=true)]
public int Value { get; set; }

// Navigation
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public Parent Parent { get; set; }
}

After letting the application create the DB schema from an empty database, I see this index in SQL Server (using "Script As Create" from SSMS):

```
CREATE UNIQUE NONCLUSTERED INDEX [IX_ParentId_Value] ON [dbo].[Children]
(
[Value] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
```

Where has the other specified column gone?

This seems to be an issue where the missing column is part of the PK that is shared with the one part of the one to many relationship.

NB. Using the fluent interface:

mb.Entity<Child>().Property(c => c.ParentId)
.HasColumnAnnotation("Index",
new IndexAnnotation(
new IndexAttribute("IX_ParentId_Value", 1) {
IsUnique = true
}));
mb.Entity<Child>().Property(c => c.Value)
.HasColumnAnnotation("Index",
new IndexAnnotation(
new IndexAttribute("IX_ParentId_Value", 2) {
IsUnique = true
}));

gives the same result.

Full solution zipped and attached.
Comments: This looks like a legitimate issue when using indexes on models that have foreign key relationships with multiple keys

Commented Unassigned: Explicit Composite Index Only Inludes One of Two Specified Columns [2382]

$
0
0

EF 6.1.1, Code First, VS2013 Premium, C# Console Application. Targeting SQL Server 2014 Dev Ed.

Given this entity:

public class Child {
[Key, Column(Order=0)]
public int GrandParentId { get; set; }

[Key, Column(Order=1)]
[Index("IX_ParentId_Value", Order=1, IsUnique=true)]
public int ParentId { get; set; }

[Key, Column(Order=2)]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ChildId { get; set; }

[Required]
[Index("IX_ParentId_Value", Order=2, IsUnique=true)]
public int Value { get; set; }

// Navigation
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public Parent Parent { get; set; }
}

After letting the application create the DB schema from an empty database, I see this index in SQL Server (using "Script As Create" from SSMS):

```
CREATE UNIQUE NONCLUSTERED INDEX [IX_ParentId_Value] ON [dbo].[Children]
(
[Value] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
```

Where has the other specified column gone?

This seems to be an issue where the missing column is part of the PK that is shared with the one part of the one to many relationship.

NB. Using the fluent interface:

mb.Entity<Child>().Property(c => c.ParentId)
.HasColumnAnnotation("Index",
new IndexAnnotation(
new IndexAttribute("IX_ParentId_Value", 1) {
IsUnique = true
}));
mb.Entity<Child>().Property(c => c.Value)
.HasColumnAnnotation("Index",
new IndexAnnotation(
new IndexAttribute("IX_ParentId_Value", 2) {
IsUnique = true
}));

gives the same result.

Full solution zipped and attached.
Comments: Investigation Results: I was able to create indexes that reference multiple columns by manually editing the generated migrations code to reflect the correct model. Beyond this, it looks like we are not correctly handling multiple index attributes.

Edited Unassigned: Explicit Composite Index Only Inludes One of Two Specified Columns [2382]

$
0
0

EF 6.1.1, Code First, VS2013 Premium, C# Console Application. Targeting SQL Server 2014 Dev Ed.

Given this entity:

public class Child {
[Key, Column(Order=0)]
public int GrandParentId { get; set; }

[Key, Column(Order=1)]
[Index("IX_ParentId_Value", Order=1, IsUnique=true)]
public int ParentId { get; set; }

[Key, Column(Order=2)]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ChildId { get; set; }

[Required]
[Index("IX_ParentId_Value", Order=2, IsUnique=true)]
public int Value { get; set; }

// Navigation
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public Parent Parent { get; set; }
}

After letting the application create the DB schema from an empty database, I see this index in SQL Server (using "Script As Create" from SSMS):

```
CREATE UNIQUE NONCLUSTERED INDEX [IX_ParentId_Value] ON [dbo].[Children]
(
[Value] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
```

Where has the other specified column gone?

This seems to be an issue where the missing column is part of the PK that is shared with the one part of the one to many relationship.

NB. Using the fluent interface:

mb.Entity<Child>().Property(c => c.ParentId)
.HasColumnAnnotation("Index",
new IndexAnnotation(
new IndexAttribute("IX_ParentId_Value", 1) {
IsUnique = true
}));
mb.Entity<Child>().Property(c => c.Value)
.HasColumnAnnotation("Index",
new IndexAnnotation(
new IndexAttribute("IX_ParentId_Value", 2) {
IsUnique = true
}));

gives the same result.

Full solution zipped and attached.

Commented Unassigned: Explicit Composite Index Only Inludes One of Two Specified Columns [2382]

$
0
0

EF 6.1.1, Code First, VS2013 Premium, C# Console Application. Targeting SQL Server 2014 Dev Ed.

Given this entity:

public class Child {
[Key, Column(Order=0)]
public int GrandParentId { get; set; }

[Key, Column(Order=1)]
[Index("IX_ParentId_Value", Order=1, IsUnique=true)]
public int ParentId { get; set; }

[Key, Column(Order=2)]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ChildId { get; set; }

[Required]
[Index("IX_ParentId_Value", Order=2, IsUnique=true)]
public int Value { get; set; }

// Navigation
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public Parent Parent { get; set; }
}

After letting the application create the DB schema from an empty database, I see this index in SQL Server (using "Script As Create" from SSMS):

```
CREATE UNIQUE NONCLUSTERED INDEX [IX_ParentId_Value] ON [dbo].[Children]
(
[Value] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
```

Where has the other specified column gone?

This seems to be an issue where the missing column is part of the PK that is shared with the one part of the one to many relationship.

NB. Using the fluent interface:

mb.Entity<Child>().Property(c => c.ParentId)
.HasColumnAnnotation("Index",
new IndexAnnotation(
new IndexAttribute("IX_ParentId_Value", 1) {
IsUnique = true
}));
mb.Entity<Child>().Property(c => c.Value)
.HasColumnAnnotation("Index",
new IndexAnnotation(
new IndexAttribute("IX_ParentId_Value", 2) {
IsUnique = true
}));

gives the same result.

Full solution zipped and attached.
Comments: This does not appear to be a regression, but has been an issue since the introduction of the Index attribute

Commented Unassigned: Performance problem EF 6 Startup and update. [2337]

$
0
0
Im using lazyloading and pre generated views.
I create the context.
I get all my objects about 6000 + navigations are filled in like 3sec. thats ok.
I update all my objects first time ( 4mins....)
I update all my objects second time ( 6sec )

I suspect lazyloading running on background and updating must be doing something that makes him reloop...

I'm on EF 6.1 and the datas are hierarchical.


Any Workaround ?
Comments: Hi Wellet, At this point the code snippets you've provided are not enough for us to perform a full investigation of the issue. Please let us know if you can attach a full repro project in a zip file, so we can profile and try to detect where the problems are coming from. David.

Commented Feature: Better auditing interception [1671]

$
0
0
Together will all the fabulous features you are introducing I think it could be find room also for a sort of Audit System more business oriented.
We love the new Log & Interceptor hooks but we also need to pull out of the DbContext an easy POCO object based on 3 level of entities like this:
- (S)avedChangset (1 instance for every SaveChanges() call with at least Time, User, Application & Session Info)
- (E)ntities (a collection of the Entities changed within the same "Saved Changset" with at least TableName & PK)
- (A)ttributes (a collection of Attributes changed within the same "Entity", with at least ColumnName, old-data, new-data)
Built with the aim to fill a three tables DB that will be the starting point for dozens of services just like deferred Publisher/Subscriber patterns, logging, tracing, audit and so on....

and we don't love write hundreds of code lines inspecting the DbContext or some other structures, we would prefer to provide some delegates/functions/actions/what-you-prefer at static/constructor/design time to teach DbContext how to create our POCO class structure and, then, at runtime, pull out our well packaged SEA Audit Structur.

Tons of other enhancements could be realized:
like the optional mapping of this new structure with DbContext objects it-self in order to write the Audit Data into DB together with the BusinesData in the same transaction, and so on....
Comments: A nice bit of code. Two thoughts come to mind: 1. If you are using SQL Server 2008 and beyond, this change tracking can be turned on automatically at the database level and the changes will be written out for you. 2. As the context and classes are generated by the template, you could modify the template to duplicate each data entity with the entity name suffix as _History. You can then add the [NotMapped] attributes to a separate meta data class which is attached to the *_History class.

Reviewed: EF 6.1.0 (ago 28, 2014)

$
0
0
Rated 5 Stars (out of 5) - Probando el framework

Commented Unassigned: Code first 6.1 and Fluent Api get metadata too slow [2423]

$
0
0
I have an application that use multiple contexts of different databases, one with 700 entities and other with a 100, 20... I have implemented the models using Code First and Fluent api, when execute metadata = ((IObjectContextAdapter)context).ObjectContext.MetadataWorkspace or execute first query is taken no less than 35 seconds, my machine have four procesor I7 and 8 gb or Ram, I reviewed several articles on performance as in Code First http://www.fusonic.net/en/blog/2014/07/09/three-steps-for-fast-entityframework-6.1-first-query-performance/, but when using multiple contexts are not i do to develop the cache, so even though I suppose the continue, more than 10 seconds is too slow. My current model based in poco entities and metadata attributes work immediately, but I want migrate to EF.

I wonder if this will be corrected soon?

Thank you.
Comments: Hi Juan, We took your project (from MaldivasModel.zip) and analyzed what's going on. In one of our development machines we wrote a simple test: ```C# Database.SetInitializer<MaldivasContext>(null); using (var ctx = new MaldivasContext()) { var sw = Stopwatch.StartNew(); var metadata = ((IObjectContextAdapter) ctx).ObjectContext.MetadataWorkspace; sw.Stop(); Console.WriteLine("Metadata obtained in {0}ms (success:{1})", sw.ElapsedMilliseconds, metadata != null); } ``` We did not use pregenerated views. The test completed in 17.5 seconds, average. We noticed the following: 1) We were never able to reproduce the 35 seconds to complete the load that you reported originally. The only way to get close to such a large cold-startup time for me was by reproducing [bug 2462](https://entityframework.codeplex.com/workitem/2462); however, if the database server I point to is valid (I used localhost) then the observed cold-startup time was 17.5 seconds. 2) Your model takes about 2 seconds to JIT. By ngen'ing the assembly that contains the model we trimmed 2 seconds off of the cold-startup time, and obtained 15.5 seconds. 3) We made some improvements to the model building code and trimmed it down to 13.2 seconds (or 11.2 when the assembly was ngen'd). You may reproduce these numbers using a [nightly build](https://entityframework.codeplex.com/wikipage?title=Nightly%20Builds) of EF which contains the latest perf fixes that we plan to ship with version 6.1.2. We will continue to make performance improvements on this front. David.

Created Unassigned: 0..1 relationships with key on child side do not work as expected [2478]

$
0
0
Is this really 0..1..many?

Parent Entity
{
ID,
StringField
}



Child Entity
{
ID
ParentID (FK to parent entity)
}


With the Naviagtion property on Parent.Child set as 0..1
and the Navigation Property on Child.Parent set as 1


if you do

context.Child.Include(c => c.Parent).ToList();

Only the first relationship fixup will happen - even though the database supports there potentially being many children with the same parent - all others will be null.

I know this is somewhat strange but it would be really nice if EF supported this - we have legacy code that does not allow nullable FK's so there can in theory be many children with place holder parent id of 0.



Commented Unassigned: EF 6.x Tools Support for Portable Class Libraries [2474]

$
0
0
It would be great if the EF 6.x Tools for Visual Studio supported Portable Class Libraries. The EF Power Tools supported PCL's, but the new tooling doesn't. Ant plans for this?

Cheers,
Tony
Comments: Hi Tony, Can you share the specific scenario of what regressed between the Tools for VS and the Power Tools? The EF runtime shouldn't install into a portable class library, so I would like to understand exactly how you are using PCLs with the tooling.

Edited Task: Enable view generation (probably PowerShell command) to replace EF Power Tools [2305]

$
0
0
We moved 'Reverse Engineer Code First' to the main EF Tooling but the Power Tools still contain the ability to create pre-generated mapping views. We need to provide a replacement for this in order to retire the Power Tools.

The current thinking is that we should do this as a PowerShell command that can be used in Package Manager Console.

When working on this we should consider the scenario reported here https://entityframework.codeplex.com/workitem/2428 in which the output directory of the project is changed and the datadirectory needs to be fixed before using it with SqlConnection.

Assuming we will do this in a different AppDomain we should also consider the scenario described in the comments of https://entityframework.codeplex.com/workitem/2266 about referenced configuration files that may be needed to get the full configuration.

Commented Feature: Better auditing interception [1671]

$
0
0
Together will all the fabulous features you are introducing I think it could be find room also for a sort of Audit System more business oriented.
We love the new Log & Interceptor hooks but we also need to pull out of the DbContext an easy POCO object based on 3 level of entities like this:
- (S)avedChangset (1 instance for every SaveChanges() call with at least Time, User, Application & Session Info)
- (E)ntities (a collection of the Entities changed within the same "Saved Changset" with at least TableName & PK)
- (A)ttributes (a collection of Attributes changed within the same "Entity", with at least ColumnName, old-data, new-data)
Built with the aim to fill a three tables DB that will be the starting point for dozens of services just like deferred Publisher/Subscriber patterns, logging, tracing, audit and so on....

and we don't love write hundreds of code lines inspecting the DbContext or some other structures, we would prefer to provide some delegates/functions/actions/what-you-prefer at static/constructor/design time to teach DbContext how to create our POCO class structure and, then, at runtime, pull out our well packaged SEA Audit Structur.

Tons of other enhancements could be realized:
like the optional mapping of this new structure with DbContext objects it-self in order to write the Audit Data into DB together with the BusinesData in the same transaction, and so on....
Comments: The DB change tracking is hard to get the "who" depending upon how your apps are architected and unless you are willing to modify their default schema and we also use EF with mysql quite a bit. Fortunately, I ran across http://romiller.com/2012/03/26/dynamically-building-a-model-with-code-first/ today and turns out that building the history objects dynamically and adding to the model is a piece of cake. ``` private void GenerateHistoryTypes() { var historytypes = FindAllDerivedTypes<ChangeHistory>(); AssemblyName aname = new AssemblyName("HistoryTest"); AssemblyBuilder abuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(aname, AssemblyBuilderAccess.RunAndSave); ModuleBuilder mbuilder = abuilder.DefineDynamicModule(aname.Name, aname.Name + ".dll"); foreach (var type in historytypes) { TypeBuilder tbuilder = mbuilder.DefineType(type.Name + "History", TypeAttributes.Public); var oldprops = type.GetProperties().Where(p => p.PropertyType.FullName.StartsWith("System.") && !p.PropertyType.FullName.StartsWith("System.Collections")).ToList(); FieldBuilder[] fields = new FieldBuilder[oldprops.Count]; int maxcol = 0, curcol = 0; PropertyBuilder modprop = null; for (int i = 0; i < fields.Length; i++) { var field = fields[i] = tbuilder.DefineField("_" + oldprops[i].Name, oldprops[i].PropertyType, FieldAttributes.Private); var prop = tbuilder.DefineProperty(oldprops[i].Name, PropertyAttributes.None, oldprops[i].PropertyType, Type.EmptyTypes); var getter = tbuilder.DefineMethod("get_" + oldprops[i].Name, MethodAttributes.Public | MethodAttributes.HideBySig, oldprops[i].PropertyType, Type.EmptyTypes); prop.SetGetMethod(getter); var il = getter.GetILGenerator(); il.Emit(OpCodes.Ldarg_0); // this il.Emit(OpCodes.Ldfld, field); // .Foo il.Emit(OpCodes.Ret); // return var setter = tbuilder.DefineMethod("set_" + oldprops[i].Name, MethodAttributes.Public | MethodAttributes.HideBySig, typeof(void), new Type[] { oldprops[i].PropertyType }); prop.SetSetMethod(setter); il = setter.GetILGenerator(); il.Emit(OpCodes.Ldarg_0); // this il.Emit(OpCodes.Ldarg_1); // value il.Emit(OpCodes.Stfld, field); // .Foo = il.Emit(OpCodes.Ret); // for our History objects, the PK will be the same as the PK for the related object plus ModifyDate to keep // it unique - not sure that this couldn't cause problems if two changes happened at the exactly the same time, // but to my knowledge, it hasn't happened yet but our application isn't particularly insert intensive CustomAttributeData attrdata; if ((attrdata = oldprops[i].GetCustomAttributesData().FirstOrDefault(a => a.AttributeType.Name == "KeyAttribute")) != null) { var coldata = oldprops[i].GetCustomAttributesData().FirstOrDefault(a => a.AttributeType.Name == "ColumnAttribute"); if (coldata != null) // already probably a compound key { var order = coldata.NamedArguments.FirstOrDefault(a => a.MemberName == "Order"); if (order != null) { curcol = (int)order.TypedValue.Value; if (curcol > maxcol) maxcol = curcol; } } var KeyCtor = typeof(KeyAttribute).GetConstructor(Type.EmptyTypes); var ColCtor = typeof(ColumnAttribute).GetConstructor(Type.EmptyTypes); var ColProp = new[] { typeof(ColumnAttribute).GetProperty("Order") }; var DbGCtor = typeof(DatabaseGeneratedAttribute).GetConstructor(new Type[1] { typeof(DatabaseGeneratedOption) }); prop.SetCustomAttribute(new CustomAttributeBuilder(KeyCtor, new object[0])); prop.SetCustomAttribute(new CustomAttributeBuilder(ColCtor, new object[0], ColProp, new object[1] { curcol })); prop.SetCustomAttribute(new CustomAttributeBuilder(DbGCtor, new object[1] { DatabaseGeneratedOption.None })); } else if ((attrdata = oldprops[i].GetCustomAttributesData().FirstOrDefault(a => a.AttributeType.Name == "StringLengthAttribute")) != null) { var StringLengthCtor = typeof(StringLengthAttribute).GetConstructor(new Type[1] { typeof(int) }); prop.SetCustomAttribute(new CustomAttributeBuilder(StringLengthCtor, new object[1] { attrdata.ConstructorArguments[0].Value })); } if (prop.Name == "Action") { var StringLengthCtor = typeof(StringLengthAttribute).GetConstructor(new Type[1] { typeof(int) }); prop.SetCustomAttribute(new CustomAttributeBuilder(StringLengthCtor, new object[1] { 10 })); } else if (prop.Name == "ModifyDate") { modprop = prop; // save this away for later after we know maxcol for sure } } var keyctor = typeof(KeyAttribute).GetConstructor(Type.EmptyTypes); var colctor = typeof(ColumnAttribute).GetConstructor(Type.EmptyTypes); var colprop = new[] { typeof(ColumnAttribute).GetProperty("Order") }; var dbgctor = typeof(DatabaseGeneratedAttribute).GetConstructor(new Type[1] { typeof(DatabaseGeneratedOption) }); modprop.SetCustomAttribute(new CustomAttributeBuilder(keyctor, new object[0])); modprop.SetCustomAttribute(new CustomAttributeBuilder(colctor, new object[0], colprop, new object[1] { maxcol + 1 })); modprop.SetCustomAttribute(new CustomAttributeBuilder(dbgctor, new object[1] { DatabaseGeneratedOption.None })); _histent.Add(tbuilder.Name, tbuilder.CreateType()); } abuilder.Save(aname.Name + ".dll"); } ``` Then use the method Rowan outlines to add them to the model so the tables get generated.

Commented Unassigned: Build and BuildEFTools does not generate .nupkg and .msi [2443]

$
0
0
Dear,

I cloned the entity framework git repository to get debugging support which I need to analyse some problems during my development. After cloning the repository I worked through

https://entityframework.codeplex.com/wikipage?title=Getting%20and%20Building%20EF%20Runtime and
https://entityframework.codeplex.com/wikipage?title=Getting%20and%20Building%20EF%20Tools

The dlls, pdbs and xml files are created as expected (some unit tests failed because of naming conventions with my sql server instance but I do not need to run the unit tests), but the nuget package and the msi installer is not created for me.

Because I am not reliant on nuget, this is not a problem for me. But i am using code first migrations, which needs the Enable-Migrations, Add-Migrations and Update-Database commands to be available on the nuget package manager console (I found no solution to run this comments from a c# application).

The libraries I can use normally without the msi and without the nuget package, but actually I haven't any idea on how to make the code first migrations run for me. Could you please advice me on integrate this commands?

Kind regards,
Sebastian.
Comments: The ToolingFacade will isolate the DbContext inside of an AppDomain. This is used by the NuGet commands to prevent locking the users's assembly. Using DbMigrator does everything inside the main AppDomain. There shouldn't be any functional difference, but using ToolingFacade will be slower. Adding the generated migrations to the project is exactly why the NuGet PowerShell commands exist. If you don't use them, you will need to manually put the generated migrations in the correct directory, add entries for them to the .csproj file, and rebuild your project before updating the database.

Commented Unassigned: Build and BuildEFTools does not generate .nupkg and .msi [2443]

$
0
0
Dear,

I cloned the entity framework git repository to get debugging support which I need to analyse some problems during my development. After cloning the repository I worked through

https://entityframework.codeplex.com/wikipage?title=Getting%20and%20Building%20EF%20Runtime and
https://entityframework.codeplex.com/wikipage?title=Getting%20and%20Building%20EF%20Tools

The dlls, pdbs and xml files are created as expected (some unit tests failed because of naming conventions with my sql server instance but I do not need to run the unit tests), but the nuget package and the msi installer is not created for me.

Because I am not reliant on nuget, this is not a problem for me. But i am using code first migrations, which needs the Enable-Migrations, Add-Migrations and Update-Database commands to be available on the nuget package manager console (I found no solution to run this comments from a c# application).

The libraries I can use normally without the msi and without the nuget package, but actually I haven't any idea on how to make the code first migrations run for me. Could you please advice me on integrate this commands?

Kind regards,
Sebastian.
Comments: Are you trying to debug a specific error? To what end are you bypassing the NuGet PowerShell commands?
Viewing all 10318 articles
Browse latest View live


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